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

如何解决?


当前回答

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

rvm osx-ssl-certs update

其他回答

这个问题已经解决了

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

简单的复制粘贴指令这里给出关于.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.

需要注意的是,如果您正在从一个SSL证书受内部证书颁发机构信任的源获取宝石(或者您正在通过带有SSL检查的公司web代理连接到一个外部源),请将SSL_CERT_FILE env变量指向您的证书链。这很可能只需要将您的根证书从证书存储(macOS上的系统密钥链)导出到您的shell中可访问的位置,即:

export SSL_CERT_FILE=~/RootCert.pem

我最近遇到了这个问题,并遵循了下面列出的步骤。您可能没有指向正确的OpenSSL证书。在运行:

rvm osx-ssl-certs status all
rvm osx-ssl-certs update all

and

export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

包完全运行!

临时解决方案(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