当我在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。

其他回答

同样的问题,但不同的宝石:

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

临时解决方案:gem install builder -v '3.0.0'使继续包安装成为可能

临时解决方案(Ownatik提到的):

在主路径中创建或修改一个名为.gemrc的文件,包括:ssl_verify_mode: 0这一行

这将防止捆绑程序在试图安装宝石时检查宝石的SSL证书。

对于*nix设备,'home path'意味着~/.gemrc。如果愿意,也可以创建/etc/gemrc。对于Windows XP,“home path”的意思是c:\Documents and Settings\All Users\Application Data\gemrc。对于Windows 7, C:\ProgramData\gemrc

我得到了一个类似的错误。下面是我解决这个问题的方法:在您的路径目录中,检查Gemfile。将gemfile中的源文件编辑为http而不是https并保存它。这可能会在没有SSL证书颁发的情况下安装捆绑程序

我能够追踪到rvm下载的二进制文件在OS X的OpenSSL中不能很好地发挥作用,这是旧的,不再被OS使用。

我的解决方案是在通过rvm安装Ruby时强制编译:

rvm reinstall --disable-binary 2.2

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

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

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