sudo gem install cocoapods 报错处理1

一、错误信息

objectivec 复制代码
ERROR:  SSL verification error at depth 3: self signed certificate in certificate chain (19)
ERROR:  Root certificate is not trusted (/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services)
ERROR:  SSL verification error at depth 3: self signed certificate in certificate chain (19)
ERROR:  Root certificate is not trusted (/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services)
ERROR:  SSL verification error at depth 3: self signed certificate in certificate chain (19)
ERROR:  Root certificate is not trusted (/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services)
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://gems.ruby-china.com - SSL_connect returned=1 errno=0 peeraddr=111.6.166.76:443 state=error: certificate verify failed (self signed certificate in certificate chain) (https://gems.ruby-china.com/specs.4.8.gz)
ERROR:  SSL verification error at depth 3: self signed certificate in certificate chain (19)
ERROR:  Root certificate is not trusted (/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services)
ERROR:  SSL verification error at depth 3: self signed certificate in certificate chain (19)
ERROR:  Root certificate is not trusted (/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services)

二、问题分析

  • 核心错误:网络环境(大概率是公司内网 / 代理)存在自签名证书,导致 RubyGems 无法信任远程仓库的证书链。
  • 错误类型:深度 3 的 SSL 验证失败,提示 "证书链中存在自签名证书"(错误代码 19)。
  • 不信任证书:系统不认可根证书 /C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=AAA Certificate Services。
  • 直接原因:无法从 RubyGems 源(https://gems.ruby-china.com)下载数据,因 SSL 连接时证书验证失败,导致无法找到有效 gem 包 cocoapods。

三、解决办法

一劳永逸,直接配置 RubyGems 忽略 SSL 验证

  1. 编辑 RubyGems 配置文件(没有则创建):
objectivec 复制代码
sudo vi ~/.gemrc
  1. 在文件中添加以下内容(按 i 进入编辑模式,粘贴后按 esc,输入 :wq 保存退出):
objectivec 复制代码
ssl_verify_mode: 0
sources:
  - https://gems.ruby-china.com
  1. 再次执行安装命令即可:
objectivec 复制代码
sudo gem install cocoapods
相关推荐
赤月奇2 天前
https改为http
数据挖掘·https·ssl
k7Cx7e3 天前
宝塔域名强制SSL和带www的方法
网络·网络协议·ssl
qq_316837753 天前
使用 certbot docker镜像生成阿里云域名ssl证书
阿里云·docker·ssl
文静小土豆3 天前
CentOS 7 升级 OpenSSL 3.5.4 详细指南
linux·运维·centos·ssl
biubiubiu07063 天前
Certbot 申请SSL证书的三种方式详解(Ubuntu 22.04环境)
网络·网络协议·ssl
宇宙核4 天前
FreeSSL实现域名证书免费无限自动续签续期流程
linux·服务器·ssl·持续部署
风早爽太5 天前
使用 CocoaPods 出现 SSL 证书验证失败错误的临时解决方案
ssl·cocoapods
qq_316837756 天前
caddy 使用阿里云的域名通过dns验证申请ssl证书
阿里云·云计算·ssl
无籽西瓜a8 天前
SSL/TLS工作流程以及HTTP与HTTPS详解
http·https·ssl
夜魔00910 天前
OpenCode、OpenClaw、Claude Code skill tool失败问题解决
ripgrep·fetch·error·skill·rg·opencode