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
相关推荐
Dxy123931021617 小时前
python连接minio报错:‘SSL routines‘, ‘ssl3_get_record‘, ‘wrong version number‘
开发语言·python·ssl
❀͜͡傀儡师1 天前
基于shell脚本来检测SSL证书过期并发送通知到钉钉
网络协议·钉钉·ssl
Htojk1 天前
openssl签发自签名证书的流程
网络协议·https·ssl
遇见火星1 天前
为MySQL配置SSL加密访问
mysql·adb·ssl
Arwen3032 天前
如何消除APP、软件的不安全下载提示?怎样快速申请代码签名证书?
网络·网络协议·tcp/ip·安全·php·ssl
洋葱 ☠2 天前
极简部署linux免费ssl证书Let‘s Encrypt,自动续签,nginx/apache都可以,域名指向服务器即可,无需项目
linux·nginx·ssl
wusp19942 天前
SSL 证书自动化系统架构文档
系统架构·自动化·ssl
shenghuiping20012 天前
OPSWAT https enable 问题解决
nginx·https·ssl·443·opswat
观测云5 天前
企业级域名 SSL 证书信息采集与巡检
ssl·观测云
充值修改昵称5 天前
SSL/TLS加密协议全面解析
网络·安全·ssl