hostname “upyun.gems.ruby-china.org” does not match the server certificate

安装cocoapods时候出现错误如下:

sudo gem install cocoapods
ERROR: While executing gem … (OpenSSL::SSL::SSLError)
hostname “upyun.gems.ruby-china.org” does not match the server certificate

解决方法如下:

查看当前ruby源列表

gem source -l

如果显示:

\* CURRENT SOURCES *
https://ruby.taobao.org/

添加新的ruby源即可解决

gem sources –r https://ruby.taobao.org/
gem sources -a https://gems.ruby-china.org
sudo gem update –system

最后重新安装cocoapods

sudo gem install cocoapods

如果报以下错误:

ERROR:  While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/xcodeproj

解决方案1:

sudo gem install -n /usr/local/bin cocoapods
pod setup

如果依旧有错误,使用第二个方案

解决方案2:

执行下面的命令并重启

sudo nvram boot-args="rootless=0"
sudo reboot

重启之后, 执行这个命令检查

sudo gem install cocoapods -V

还有一点需要注意,pod setup在执行时,会输出Setting up CocoaPods master repo,但是会等待比较久的时间。这步其实是 Cocoapods 在将它的信息下载到 ~/.cocoapods目录下,如果你等太久,可以试着 cd 到那个目录,用du -sh *来查看下载进度。

安装成功后,你会看到:Setup completed

你可能感兴趣的:(hostname “upyun.gems.ruby-china.org” does not match the server certificate)