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
相关推荐
前进的程序员1 分钟前
OpenSSL加解密原理及使用方法详解
ssl·加解密·openssl
星夜落月1 天前
Certimate证书自动化管理:从零开始的私有化部署指南
运维·自动化·ssl
Genie cloud3 天前
1Panel SSL证书申请完整教程
服务器·网络协议·云计算·ssl
mftang3 天前
现代互联网安全的基石: SSL/TLS技术介绍
服务器·网络·ssl
吠品3 天前
什么是 IP SSL 证书?该如何申请
网络协议·tcp/ip·ssl
JoySSLLian4 天前
IP SSL证书:一键解锁IP通信安全,高效抵御网络威胁!
网络·人工智能·网络协议·tcp/ip·ssl
小白电脑技术4 天前
飞牛绑定免费二级域名ccwu.cc后部署SSL证书教程
网络协议·https·ssl
2401_865854884 天前
腾讯云应用防火墙和阿里云的有什么区别
安全·ssl
七夜zippoe5 天前
网络安全实战:从TLS/SSL到JWT与OAuth2.0的完整防御体系构建
网络·安全·web安全·ssl·tls
hjhcos6 天前
【宝塔】局域网IP申请SSL证书,解决浏览器本地环境可以访问摄像头,发布环境不能访问摄像头的问题
网络协议·tcp/ip·ssl