简体   繁体   中英

Could not verify the SSL certificate for https://rubygems.org/

I'm getting this error when I run bundle install :

Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely 
your system doesn't have the CA certificates needed for verification. For
information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without using 
SSL, edit your Gemfile sources and change 'https' to 'http'.

However, it is only happening to one of my projects, and seems to be happening to only me. Also, I can get around it by running bundle update , where I don't get that error, and I can get up a running after that.

Is there something that isn't tracked in the project (that is only on my machine) that I have misconfigured?

I had this problem on Mac OS X Yosemite with ruby 2.3.1. I fixed the problem by downloading http://curl.haxx.se/ca/cacert.pem to /usr/local/etc/openssl/

and adding this line export SSL_CERT_FILE=/usr/local/etc/openssl/cacert.pem to .bash_profile

Credit to Can't run Ruby 2.2.3 with RVM on OSX but it was hard to google the right answer, so added to this page.

The solution for me on OS X 10.9.5 was to sudo rvm osx-ssl-certs update all .

Source: http://jacopretorius.net/2013/10/could-not-verify-the-ssl-certificate-for-rubygems.html

运行gem update --system为我工作

Since I am using rbenv instead of rvm , I wasn't able to do most of the solutions online.

I was able to fix the issue by uninstalling and reinstalling openssl

All is well, but I am not exactly sure why.

对于 linux 用户,只需安装软件包: ca-certificates

升级 openssl 应该可以解决这个问题。(如果是 MacOSX)

brew upgrade openssl

使用 OSX 10.14.6和 Rails 6 这对我10.14.6

rvm osx-ssl-certs update

Maybe this method will be useful

1.Switch source to https://gems.ruby-china.org/

$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/

2.Check current source

$ gem sources -l

*** CURRENT SOURCES ***

https://gems.ruby-china.org

3.Mirror gem source

$ bundle config mirror.https://rubygems.org https://gems.ruby-china.org

Through these methods, you will not need to change Gemfile souce .

Hope this method will be useful for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM