我在做迈克尔·哈特尔的教程。当我试图在我的gemset中安装rails 3.2.14时,我得到以下问题:

$ gem install rails -v 3.2.14 错误:无法找到一个有效的宝石'rails'(= 3.2.14),这是为什么: 无法从https://rubygems.org/下载数据- SSL_connect返回=1 errno=0 state=SSLv3读取服务器证书B:证书验证失败(https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz)

在谷歌搜索之后,我发现我可以使用rubygems的非ssl源代码,所以我运行:

sudo gem sources -a http://rubygems.org

然后,当我再次尝试安装rails时,它成功了。然而,我仍然有上面的问题,但作为一个警告:

警告:无法从'https://rubygems.org/': SSL_connect returned=1 errno=0 state=SSLv3读取服务器证书B:证书验证失败(https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz)

如何完全删除此警告/错误?

我正在使用以下:

rvm 1.22.15 Ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0] OSX 10.8.5


当前回答

尝试使用宝石的源网站,如rubygems.org。使用http而不是https。这种方法不涉及任何工作,如安装证书和所有的。

的例子,

gem install typhoeus --source http://rubygems.org

这是可行的,但有一个警告。

gem已经安装,但是文档没有安装,因为存在证书错误。这是我得到的错误

Parsing documentation for typhoeus-0.7.0 WARNING: Unable to pull 
data from 'https://rubygems.org/': SSL_connect returned=1 errno=0 
state=SSLv3 read server certificate B: certificate verify failed 
(https://rubygems.org/latest_specs.4.8.gz)

其他回答

可以使用HTTP而不是HTTPS自动下载gems的方法/一行程序:

printf -- '---\n:sources:\n- http://rubygems.org\n' | tee ~/.gemrc

对于Illumos / Solaris使用OpenCSW pkgutil:

在“gem Install”之前安装cswcacercertificates

pkgutil -yi CSWcacertificates

如果您使用的ruby套件不是来自OpenCSW,那么您的ruby版本可能希望在另一个地方找到证书文件。在本例中,我只是符号链接了OpenCSW的/etc/opt/csw/ssl/cert.Pem到预期的位置。

看看ruby希望在哪里找到它:

export cf=`ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'` && echo $cf

然后,如果有差异,链接它:

ln -s /etc/opt/csw/ssl/cert.pem $cf && file $cf

作为一名Windows 10用户,我遵循了Dheerendra的答案,有一天它对我起了作用。第二天,我又遇到了这个问题,他的修复不起作用。对我来说,修复是更新捆绑器:

Gem更新绑定器

我相信我的bundler版本是几个月前的。

Try

gem update --system

希望这能解决问题。

尝试使用宝石的源网站,如rubygems.org。使用http而不是https。这种方法不涉及任何工作,如安装证书和所有的。

的例子,

gem install typhoeus --source http://rubygems.org

这是可行的,但有一个警告。

gem已经安装,但是文档没有安装,因为存在证书错误。这是我得到的错误

Parsing documentation for typhoeus-0.7.0 WARNING: Unable to pull 
data from 'https://rubygems.org/': SSL_connect returned=1 errno=0 
state=SSLv3 read server certificate B: certificate verify failed 
(https://rubygems.org/latest_specs.4.8.gz)