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

20,515

Solution 1

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.

Solution 2

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

Solution 3

Running gem update --system worked for me

Solution 4

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

Solution 5

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.

Share:
20,515
cdpalmer
Author by

cdpalmer

Most up to date skills are Ruby/Rails and React. Love clean questions and answers, probably like code structure and appearance more than I should.

Updated on December 08, 2020

Comments

  • cdpalmer
    cdpalmer over 3 years

    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?

  • 23tux
    23tux over 10 years
    here is also a good solution: stackoverflow.com/questions/19150017/…
  • rejin
    rejin over 9 years
    dont try this, man. most of my Dependant packages got removed as result.
  • userFriendly
    userFriendly over 7 years
    In case it is not obvious to Zsh users, add the export line to .zshrc
  • Mikel
    Mikel over 5 years
    This fixed the problem for me, using rbenv on Ubuntu 18.04.1
  • cdpalmer
    cdpalmer over 5 years
    Updated this as a better answer due to upvotes (and my solution was 5 years old)
  • Sohair Ahmad
    Sohair Ahmad over 2 years
    This solution worked for me too. For Mac OSX BigSur, Ruby 2.6.4 and RVM 1.29.7 (1.29.7)