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
相关推荐
阿凤212 天前
nginx部署如何配置ssl证书
运维·nginx·ssl
AscendKing2 天前
一款开源、本地部署的 SSL 证书自动化管理工具Certimate介绍 部署教程
开源·自动化·ssl
MonkeyKing_sunyuhua2 天前
Nginx + Let’s Encrypt 免费 SSL 证书 的完整配置过程
运维·nginx·ssl
wAEWQ6Ib74 天前
当今互联网安全的基石 - TLS/SSL
网络·安全·ssl
芯智工坊4 天前
第8章 Mosquitto消息高级特性
网络·人工智能·mqtt·开源·ssl
芯智工坊4 天前
第7章 Mosquitto增加SSL/TLS加密通信
网络协议·https·ssl
EmbeddedCore4 天前
低成本物联网产品放弃SSL加密的隐形成本与市场逻辑
物联网·网络协议·ssl
EmbeddedCore4 天前
守护网络通信的基石:深入解析SSL/TLS协议
网络·网络协议·ssl
EmbeddedCore5 天前
在资源受限的M3处理器上实现SSL/TLS通信的完整方案
网络协议·嵌入式·ssl
Days20505 天前
关于SSL证书签发时长调整通知
网络协议·https·ssl