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
相关推荐
其实防守也摸鱼5 小时前
DeepSeek Harness 开源贡献手记:从入门到合入主线
服务器·数据库·windows·https·ssl
其实防守也摸鱼7 小时前
堆叠注入(Stacked Injection)详解
服务器·数据库·windows·https·ssl
JamesShi1681 天前
华为云证书续费操作全流程,针对购买华为云企业门户建站的用户!
ssl
2601_967019511 天前
SSL 证书不止加密,还影响网站信任与 SEO
ssl
2601_967019512 天前
证书兼容性排查:SSL 部署后浏览器不安全告警分析
ssl
2601_967019513 天前
没有 SSL 证书的网站,会有哪些安全与流量损失?
ssl
一个心烑4 天前
配置项目git的 SSL 证书
git·网络协议·ssl
IT摆渡者6 天前
1panel 配置申请手动解析网站SSL证书
服务器·网络协议·ssl
IT摆渡者6 天前
1panel 针对HTTP自动续签SSL网站证书
网络协议·ssl·openresty
2601_967019517 天前
SSL证书是什么?HTTPS安全原理
ssl