ruby - 安装 cocoapods 时出现 SSL 验证错误
问题描述
我做了什么sudo gem install cocoapods
这是来自终端的完整消息
ERROR: You must add /C=BE/O=GlobalSign nv-sa/CN=AlphaSSL CA - SHA256 - G2 to your local trusted store
ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - hostname "rubygems.org" does not match the server certificate (https://rubygems.org/specs.4.8.gz)
ERROR: SSL verification error at depth 0: unable to get local issuer certificate (20)
我没有使用 SSL 的经验,但我遵循了几个与我类似的问题,但没有运气
我试过的:
- 下载并安装新的 SHA256 中间证书
- 将主机名从 https 更改为 http
- 遵循本指南,但无法将 GlobalSignRootCA.pem 复制到 ruby 文件夹
- 使用 HomeBrew 但安装时出现另一个错误
解决方案
MichaelHuelsen 有正确的答案。在这里,我将给出对我有用的分步说明,但会用一个大文件覆盖 pem 文件,因此请注意,如果其中包含您可能不想破坏的敏感信息。
- 识别证书文件。
$ ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'
"/etc/pki/tls/cert.pem"
告诉我我的证书文件在哪里。
- 备份证书文件
cp /etc/pki/tls/cert.pem /tmp/cert.pem.bak
- 通过 curl 复制完整的证书文件
见:https ://curl.se/docs/caextract.html
curl --remote-name --time-cond cacert.pem https://curl.se/ca/cacert.pem
- 移动新的 cacert.pem 文件以替换旧文件
mv cacert.pem /etc/pki/tls/cert.pem
然后我跑去gem update --system
更新东西,但你可能只是可以运行你原来的gem
命令。
推荐阅读
- shell - 通过 shell 将事件发送到本地数据狗代理
- reactjs - 测试是否已使用 Jest 调用了 React prop 方法
- python - 从 2d numpy 数组创建 3d numpy 数组
- r - 使用对数刻度时的倒置密度图
- python - 让笔记本识别 conda env ( ImportError: cannot import name 'ensure_dir_exists' )
- vue.js - 动态 img src 连接到 vue.js
- swift - 将字符串格式化为日期格式 swift
- iis - 在 IIS 10.0 中使用命令行 VSIISExeLauncher.exe 启动进程失败
- php - 联系表单提交后的模态弹出窗口
- php - 如何使用 setlocale 将日期更改为西班牙语格式?