尝试使用 cocoapods 克隆 git repo 的 SSL 验证问题

SSL verification problems trying to clone git repo with cocoapods

我刚刚创建了一个新的 Xcode 8 项目,我正在尝试通过 CocoaPods 安装 Alamofire。 在 pod install 之后我收到了这个错误:

[!] Error installing Alamofire
[!] /usr/bin/git clone https://github.com/Alamofire/Alamofire.git /var/folders/18/n59jh6715l38t9wsmbgv5yvc0000gp/T/d20160926-3719-16da22u --template= --single-branch --depth 1 --branch 4.0.1

Cloning into '/var/folders/18/n59jh6715l38t9wsmbgv5yvc0000gp/T/d20160926-3719-16da22u'...
fatal: unable to access 'https://github.com/Alamofire/Alamofire.git/': SSL: certificate verification failed (result: 5)`

上周五我将另一个库安装到另一个 Xcode 8 项目中,完全没有问题,所以我真的不知道该怎么做。 在这两种情况下,我都使用了带有 MacOs Sierra 的 Macbook Pro。

您在 CocoaPods-app issue 355 中有一张类似的票。

如果它以前能用,现在不能用,那么这两个 pod 安装实例之间一定有什么不同。用户不同,或者所涉及的 url 不同(例如之前的 ssh 与现在的 https)

作为 suggested here or in this issue,检查您的全局 git 配置 (~/.gitconfig) 并删除 slCAInfosslVerify 设置以查看问题是否仍然存在。
或者检查你是否 have an environment variable SSL_CERT_FILE currently active (exported). (also mentioned in this issue)

尝试使用 ssh 是否效果更好:

git config --global url."git@github.com/Alamofire".insteadOf https://github.com/Alamofire

作为 OP Aleph72 commented :

My slCAInfo line in the git config was pointing to an exported .pem file that included two certificates, and one of those expired few days ago.

因此删除 sslCAinfo 设置会有所帮助。