当我在Centos 5.5上为我的Rails 3项目运行捆绑安装时,它失败了,出现了一个错误:

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 
read server certificate B: certificate verify failed 
(https://bb-m.rubygems.org/gems/multi_json-1.3.2.gem)
An error occured while installing multi_json (1.3.2), and Bundler cannot continue.
Make sure that `gem install multi_json -v '1.3.2'` succeeds before bundling.

当我尝试手动安装gem(通过gem install multi_json -v '1.3.2')它工作。同样的问题也发生在其他宝石上。我使用RVM (1.12.3), ruby 1.9.2, bundle 1.1.3。

如何解决?


当前回答

在Ubuntu 12.04上,我得到了一个稍微不同的错误,尽管可能相关:

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=unknown state: sslv3 alert handshake failure (https://d2chzxaqi4y7f8.cloudfront.net/gems/activesupport-3.2.3.gem)
An error occured while installing activesupport (3.2.3), and Bundler cannot continue.
Make sure that `gem install activesupport -v '3.2.3'` succeeds before bundling.

当我在Gemfile中使用源文件“https://rubygems.org”运行bundle install时,就会发生这种情况。

这是Ubuntu 12.04上OpenSSL的一个问题。参见Rubygems第319期。

要解决这个问题,请在Ubuntu 12.04上运行apt-get update && apt-get upgrade来升级您的OpenSSL。

其他回答

这是如何在Windows上解决这个问题:

然后在命令提示符中设置SSL_CERT_FILE

https://gist.github.com/fnichol/867550

对我来说,在遗留的windows系统和ruby 1.9版本上唯一有效的方法是从 http://guides.rubygems.org/ssl-certificate-update/

然后在运行bundle install之前运行下面的命令

bundle config --global ssl_ca_cert /path/to/file.pem

将ssl gem源替换为非ssl作为临时解决方案:

宝石来源-r https://rubygems.org/ 宝石来源- http://rubygems.org/

对于那些通过RVM安装了ruby并想要快速修复的人(更喜欢不按Bruno的要求阅读),请尝试以下方法:

rvm remove 1.9.x (or whatever version of ruby you are using)
rvm pkg install openssl
rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr

要了解更多细节,这里是我找到解决方案的链接。

http://railsapps.github.com/openssl-certificate-verify-failed.html

顺便说一句,我在Ubuntu上不需要修改我的证书。

最重要的是,这不是一个变通办法。它将下载宝石通过 SSL和失败,如果有如果有一个人在中间的问题 这比关闭安全系统强多了。

这个问题已经解决了

http://guides.rubygems.org/ssl-certificate-update/

现在是RubyGems 2.6。X已经发布,您可以手动更新到此版本。

下载https://rubygems.org/downloads/rubygems-update-2.6.7.gem

请将该文件下载到您稍后可以指向的目录中(例如。你的硬盘根目录C:)

现在,使用命令提示符:

C:\>gem install --local C:\rubygems-update-2.6.7.gem
C:\>update_rubygems --no-ri --no-rdoc

在此之后,gem——version应该报告新的更新版本。

您现在可以安全地卸载rubygems-update gem:

C:\>gem uninstall rubygems-update -x