cocoapods安裝SSL證書問題
問題:安裝cocoapods 報SSL證書的問題,如下錯誤
ERROR: SSL verification error at depth 2: 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 2: self-signed certificate in certificate chain (19)
ERROR: Root certificate is not trusted (/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root CA)
Successfully installed cocoapods-1.11.2
Parsing documentation for cocoapods-1.11.2
Done installing documentation for cocoapods after 1 seconds
1 gem installed
[!] Couldn't determine repo type for URL: `https://cdn.cocoapods.org/`: SSL_connect returned=1 errno=0 peeraddr=172.67.74.167:443 state=error: certificate verify failed (unable to get local issuer certificate)
解決方案:
1.下載證書
可以使用 wget 下載或者直接在網頁下載
https://curl.se/ca/cacert.pem
2.設置環境變量
vim /etc/profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
# 設置環境變量的路徑,/root/cacert.pem為下載證書后放的位置
export SSL_CERT_FILE=/root/cacert.pem
source /etc/profile
3.安裝cocoapods,指定版本1.11.2
sudo gem install -n /usr/local/bin cocoapods -v 1.11.2
注釋:使用gem安裝問題有點小多,如果不需要指定版本可以選擇brew安裝最新的版本。終端輸入 : brew install cocoapods 即可

浙公網安備 33010602011771號