解决Window的gem ssl报错问题

1.修改gem源

查看源:gem sources -l 
图内镜像:gem sources -a https://gems.ruby-china.com/
删除源:gem sources -r https://rubygems.org/ 

提示证书验证失败:

C:\>gem sources -a https://gems.ruby-china.com/
Error fetching https://gems.ruby-china.org/:
        SSL_connect returned=1 errno=0 state=SSLv3 read server
rtificate verify failed (https://gems.ruby-china.org/specs.4.8.gz)

解决:

下载证书:
http://curl.haxx.se/ca/cacert.pem
设置环境变量:
SSL_CERT_FILE=<证书存放路径>
如:SSL_CERT_FILE=d:\RailsInstaller\cacert.pem
重启命令行,再次执行命令

如果还有问题,在命令行里执行

set SSL_CERT_FILE=<证书存放路径>

2.修改rails默认源

bundle config 'mirror.https://rubygems.org' 'https://gems.ruby-china.com/'

小结:安装openssl太麻烦,此方法已验证,可以解决证书问题,gem可用即可
参考:http://railsapps.github.io/openssl-certificate-verify-failed.html
https://gist.github.com/fnichol/867550

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。