20

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?

cdpalmer
  • 658
  • 1
  • 7
  • 19
  • 5
    Try this: ```gem update --system``` and then if you are on a MAC try this: ```rvm osx-ssl-certs update``` – Nobita Nov 21 '13 at 16:27
  • Also check that your system has the correct date/time. (For example, if it's a virtual machine, it could lose the time if you hibernate the host.) – crestor May 23 '17 at 07:38

8 Answers8

26

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.

Community
  • 1
  • 1
Michael Klishevich
  • 1,774
  • 1
  • 17
  • 17
12

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

Micah Alcorn
  • 2,363
  • 2
  • 22
  • 45
5

Running gem update --system worked for me

user3408293
  • 1,377
  • 6
  • 18
  • 26
3

For linux users, simply install the package: ca-certificates

Jordan Morris
  • 2,101
  • 2
  • 24
  • 41
2

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.

cdpalmer
  • 658
  • 1
  • 7
  • 19
  • 1
    here is also a good solution: http://stackoverflow.com/questions/19150017/ssl-error-when-installing-rubygems-unable-to-pull-data-from-https-rubygems-o – 23tux Dec 09 '13 at 18:04
  • 1
    dont try this, man. most of my Dependant packages got removed as result. – rejin Nov 06 '14 at 07:05
1

Upgrading openssl should fix the issue.(if it's MacOSX)

brew upgrade openssl
1

Using OSX 10.14.6 and Rails 6 this worked for me:

rvm osx-ssl-certs update

lcjury
  • 1,158
  • 1
  • 14
  • 26
-3

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.

JonyFang
  • 5
  • 2