【问题标题】:Could not verify the SSL certificate for https://rubygems.org/无法验证 https://rubygems.org/ 的 SSL 证书
【发布时间】:2013-12-06 05:43:39
【问题描述】:

我在运行 bundle install 时收到此错误:

Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely 
your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without using 
SSL, edit your Gemfile sources and change 'https' to 'http'.

但是,它只发生在我的一个项目中,而且似乎只发生在我身上。另外,我可以通过运行 bundle update 来解决它,我没有收到该错误,然后我可以开始运行。

我配置错误的项目(仅在我的机器上)中是否存在未跟踪的内容?

【问题讨论】:

  • 试试这个:gem update --system,然后如果你在 MAC 上试试这个:rvm osx-ssl-certs update
  • 还要检查您的系统是否有正确的日期/时间。 (例如,如果它是一个虚拟机,如果你让主机休眠,它可能会浪费时间。)

标签: ruby-on-rails ruby git ssl github


【解决方案1】:

我在使用 ruby​​ 2.3.1 的 Mac OS X Yosemite 上遇到了这个问题。 我通过将http://curl.haxx.se/ca/cacert.pem 下载到 /usr/local/etc/openssl/

并将这一行 export SSL_CERT_FILE=/usr/local/etc/openssl/cacert.pem 添加到 .bash_profile

感谢Can't run Ruby 2.2.3 with RVM on OSX,但很难用谷歌搜索正确的答案,所以添加到此页面。

【讨论】:

  • 如果对 Zsh 用户不明显,请将导出行添加到 .zshrc
  • 由于赞成票将其更新为更好的答案(我的解决方案已有 5 年历史)
  • 这个解决方案也对我有用。适用于 Mac OSX BigSur、Ruby 2.6.4 和 RVM 1.29.7 (1.29.7)
【解决方案2】:

我在 OS X 10.9.5 上的解决方案是 sudo rvm osx-ssl-certs update all

来源:http://jacopretorius.net/2013/10/could-not-verify-the-ssl-certificate-for-rubygems.html

【讨论】:

    【解决方案3】:

    跑步 gem update --system 为我工作

    【讨论】:

      【解决方案4】:

      对于 linux 用户,只需安装软件包:ca-certificates

      【讨论】:

      • 这解决了我的问题,在 Ubuntu 18.04.1 上使用 rbenv
      【解决方案5】:

      由于我使用的是rbenv 而不是rvm,因此我无法在线完成大部分解决方案。

      我能够通过卸载并重新安装openssl来解决这个问题

      一切都很好,但我不确定为什么。

      【讨论】:

      【解决方案6】:

      升级 openssl 应该可以解决问题。(如果是 MacOSX)

      brew upgrade openssl
      

      【讨论】:

        【解决方案7】:

        使用 OSX 10.14.6 和 Rails 6 这对我有用:

        rvm osx-ssl-certs update

        【讨论】:

          【解决方案8】:

          也许这个方法会有用

          1.切换源到https://gems.ruby-china.org/

          $ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
          

          2.检查当前来源

          $ gem sources -l
          
          *** CURRENT SOURCES ***
          
          https://gems.ruby-china.org
          

          3.镜像gem源码

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

          通过这些方法,您将无需更改Gemfile souce

          希望这个方法对你有用。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2015-04-21
            • 1970-01-01
            • 2017-05-27
            • 2013-09-26
            • 1970-01-01
            • 2017-03-25
            • 2010-11-30
            相关资源
            最近更新 更多