美文网首页RubyRuby on RailsRuby、Rails知识
解决Window的gem ssl报错问题

解决Window的gem ssl报错问题

作者: ahtest | 来源:发表于2018-06-06 09:40 被阅读3次

    1.修改gem源

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

    提示证书验证失败:

    C:\>gem sources -a https://gems.ruby-china.org/
    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.org/'
    

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

    相关文章

      网友评论

        本文标题:解决Window的gem ssl报错问题

        本文链接:https://www.haomeiwen.com/subject/vnwvsftx.html