Certificate Verify Failed in “gem install foundation”

一世执手 提交于 2019-11-29 06:37:09

问题


Trying to install Foundation after installing nodejs, ruby, and git plus bower.

I keep getting the following error and I dont know how to fix it:

Could not find a valid gem 'foundation' (>= 0), here is why: Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/latest_specs.4.8.gz)

Any ideas?


回答1:


Try this (quick but insecure)

gem sources --remove https://rubygems.org/
gem sources -a http://rubygems.org/

NOTE : Downloading over HTTP will be unencrypted




回答2:


If you're using RVM (highly recommended) you can run

rvm osx-ssl-certs update all

Otherwise you can follow the directions at http://guides.rubygems.org/ssl-certificate-update/ and while the update_rubygems patch didn't do anything for me, manually installing the .pem file probably would have worked.

Without RVM the link suggests that you can try...

gem install bundler

or

gem update --system



回答3:


Look at this, the issue is explained in detail:

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




回答4:


Please read the background and follow the official guide from rubygems.org on how to fix this.

TL;DR:

  1. Download rubygems-update-2.6.7.gem (link will be stale when new version is out)
  2. gem install --local $USER\Downloads\rubygems-update-2.6.7.gem
    (Try %userprofile% instead of $USER if using Windows)
  3. update_rubygems --no-ri --no-rdoc
  4. gem uninstall rubygems-update -x



回答5:


Taken from the reference given by Sébastien

Basicaly, you download the latest certificate and place it in $RUBYHOME/lib/ruby/2.1.0/rubygems/ssl_certs. (Note that you might have a different version of rubygems installed than 2.1.0, so adjust the path appropriately).

Rubygems should be using the certificate the next time you call the gem command.




回答6:


You need to update your gem installation to the version 2.6.7. Try this solution here:

https://github.com/rubygems/rubygems/issues/1770

http://guides.rubygems.org/ssl-certificate-update/#installing-using-update-packages




回答7:


On linux, or in a docker container the following command will solve the problem:

curl https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem > $(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE')

The above command will fetch the CA cert that rubygems expects when connecting to its website and install it in the location that ruby expects the cert to live.

Thanks to Gabe Evans helpful blog post, for detailing a smart way of solving the problem in one line of code.

I modified Gabe's solution to use the CA cert specified on the rubygems website. Further discussion of why this problem arose can be found there.

The benefit of this solution is that it uses https to fetch the updated cert for rubygems. Since it fetches this cert from github it can work even with a SHA1 cert. It is also handy because it uses ruby, by pulling in the openssl library to place the cert where it needs to go.



来源:https://stackoverflow.com/questions/27573248/certificate-verify-failed-in-gem-install-foundation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!