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

如何解决?


当前回答

更新

现在我已经从这个答案中得到了足够的报应,每个人都应该知道这应该被解决。

re:通过Ownatik再次捆绑安装失败,SSL证书验证错误

gem update --system

我的答案仍然是正确的,如果最终不适合你,请参考下面的答案。


老实说,最好的临时解决办法就是

[…在你的gemfile中使用非ssl版本的rubygems作为临时的解决方案。

通过用户Ownatik

它们的意思是在Gemfile的顶部在您的rails应用程序目录更改

源“https://rubygems.org”

to

源“http://rubygems.org”

注意,第二个版本是HTTP而不是HTTPS

其他回答

在windows7上可以下载cacert。将环境变量SSL_CERT_FILE设置为您存储证书的路径

SET SSL_CERT_FILE="C:\users\<username>\cacert.pem"

或者你可以在脚本中这样设置变量ENV['SSL_CERT_FILE']="C:/users/<username>/cacert.pem"

将<username>替换为您自己的用户名。

如果你在mac上使用最新版本的RVM(~1.20),下面的命令适合我。

rvm osx-ssl-certs update

您可以从curl的网站http://curl.haxx.se/ca/cacert.pem下载CA证书列表

然后设置SSL_CERT_FILE环境变量,告诉Ruby使用它。例如,在Linux中:

$ SSL_CERT_FILE=~/cacert.pem bundle install

(参考:https://gist.github.com/fnichol/867550)

简单的复制粘贴指令这里给出关于.pem文件

https://gist.github.com/luislavena/f064211759ee0f806c88

证书验证失败

If you've read the previous sections, you will know what this means (and shame > on you if you have not). We need to download AddTrustExternalCARoot-2048.pem. Open a Command Prompt and type in: C:>gem which rubygems C:/Ruby21/lib/ruby/2.1.0/rubygems.rb Now, let's locate that directory. From within the same window, enter the path part up to the file extension, but using backslashes instead: C:>start C:\Ruby21\lib\ruby\2.1.0\rubygems This will open a Explorer window inside the directory we indicated. Step 3: Copy new trust certificate Now, locate ssl_certs directory and copy the .pem file we obtained from previous step inside. It will be listed with other files like GeoTrustGlobalCA.pem.

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

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

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