Gem install fails with SSL certificate connection error #1736

Closed
PavelEmelyanov opened this Issue Oct 5, 2016 · 30 comments

Comments

Projects
None yet
@PavelEmelyanov

Hello, I'm having a problem. Today, when I try to execute "gem install ..." or "gem update" I have the following error:

C:\WINDOWS\system32>gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certif
icate verify failed (https://api.rubygems.org/specs.4.8.gz)

or

C:\WINDOWS\system32>gem install sass compass
ERROR:  Could not find a valid gem 'sass' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur
ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
https://api.rubygems.org/specs.4.8.gz)
ERROR:  Could not find a valid gem 'compass' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur
ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
https://api.rubygems.org/specs.4.8.gz)

I've updated ruby, but is doesn't help.

This issue is related to:

  • Network problems
  • The command line gem

Here are my current environment details:
gem 2.4.5.1
ruby 2.2.5p319 (2016-04-26 revision 54774) [x64-mingw32]

Thanks

@segiddins

This comment has been minimized.

Show comment
Hide comment
@segiddins

segiddins Oct 5, 2016

Member

You may need to update your Ruby to use a newer version of OpenSSL

Member

segiddins commented Oct 5, 2016

You may need to update your Ruby to use a newer version of OpenSSL

@PavelEmelyanov

This comment has been minimized.

Show comment
Hide comment
@PavelEmelyanov

PavelEmelyanov Oct 5, 2016

Well, I found this on http://rubyinstaller.org/downloads/

If you don’t know what version to install and you’re getting started with Ruby, we recommend you use Ruby 2.2.X installers.

So I updated my ruby to 2.2.5, but it didn't help me. Should I update ruby to 2.3.1?

Well, I found this on http://rubyinstaller.org/downloads/

If you don’t know what version to install and you’re getting started with Ruby, we recommend you use Ruby 2.2.X installers.

So I updated my ruby to 2.2.5, but it didn't help me. Should I update ruby to 2.3.1?

@ptrikutam

This comment has been minimized.

Show comment
Hide comment
@ptrikutam

ptrikutam Oct 5, 2016

I had a similar issue:

$ gem install bundler
ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

I'm running:
rvm 1.27.0
ruby ruby 2.3.1p112 (via RVM)
gem 2.6.7

I tried following a number of suggestions provided in #1050, including the solution here: https://gist.github.com/luislavena/f064211759ee0f806c88#installing-using-update-packages-new

None of those worked for me. Turns out my OS X certs were out of date, I guess.

The solution that worked for me is updating my OS X certs with brew (took the suggestions from here) :

brew update
brew install openssl
brew tap raggi/ale
brew install openssl-osx-ca

Then, doing a gem update --system and gem install bundler worked fine. Hope this helps.

ptrikutam commented Oct 5, 2016

I had a similar issue:

$ gem install bundler
ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

I'm running:
rvm 1.27.0
ruby ruby 2.3.1p112 (via RVM)
gem 2.6.7

I tried following a number of suggestions provided in #1050, including the solution here: https://gist.github.com/luislavena/f064211759ee0f806c88#installing-using-update-packages-new

None of those worked for me. Turns out my OS X certs were out of date, I guess.

The solution that worked for me is updating my OS X certs with brew (took the suggestions from here) :

brew update
brew install openssl
brew tap raggi/ale
brew install openssl-osx-ca

Then, doing a gem update --system and gem install bundler worked fine. Hope this helps.

@ckenst

This comment has been minimized.

Show comment
Hide comment
@ckenst

ckenst Oct 5, 2016

@ptrikutam thanks for the link to OpenSSL Errors and Rails – Certificate Verify Failed. Following the instructions for the section Use RVM to Fix SSL Certificates worked for me.

ckenst commented Oct 5, 2016

@ptrikutam thanks for the link to OpenSSL Errors and Rails – Certificate Verify Failed. Following the instructions for the section Use RVM to Fix SSL Certificates worked for me.

@ptrikutam

This comment has been minimized.

Show comment
Hide comment
@ptrikutam

ptrikutam Oct 5, 2016

@ckenst Glat to hear it. For what it's worth, using RVM to fix the certs didn't work for me, I had to use brew.

@ckenst Glat to hear it. For what it's worth, using RVM to fix the certs didn't work for me, I had to use brew.

@NarineM

This comment has been minimized.

Show comment
Hide comment
@NarineM

NarineM Oct 5, 2016

I am getting similar error with gem install mysql2:

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://api.rubygems.org/specs.4.8.gz)

Is this a temp issue and will go away? I am using 2.4.5 version of ruby gem. I was able to make gem download the mysql2 using [insecure] http by [redacted for security purposes]

But I do not think this could be used as long term solution.

NarineM commented Oct 5, 2016

I am getting similar error with gem install mysql2:

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://api.rubygems.org/specs.4.8.gz)

Is this a temp issue and will go away? I am using 2.4.5 version of ruby gem. I was able to make gem download the mysql2 using [insecure] http by [redacted for security purposes]

But I do not think this could be used as long term solution.

@zymzxq

This comment has been minimized.

Show comment
Hide comment
@zymzxq

zymzxq Oct 6, 2016

Same error :(

zymzxq commented Oct 6, 2016

Same error :(

@gorenm

This comment has been minimized.

Show comment
Hide comment
@gorenm

gorenm Oct 6, 2016

Same here.
Happens when trying to install bundler.

Windows 10
Ruby 2.2.4p230
gem 2.4.5.1

Edit: I was able to fix it by downloading the latest rubygems version (2.6.7) and updating from the downloaded gem.

gorenm commented Oct 6, 2016

Same here.
Happens when trying to install bundler.

Windows 10
Ruby 2.2.4p230
gem 2.4.5.1

Edit: I was able to fix it by downloading the latest rubygems version (2.6.7) and updating from the downloaded gem.

@Azolo

This comment has been minimized.

Show comment
Hide comment
@Azolo

Azolo Oct 6, 2016

So, the reason why this is happening is because rubygems.org updated their SSL certificate and older versions don't have the updated certificate bundled.

If you're using a traditional OpenSSL distribution then updating it would likely pull in new certificates that include the new rubygems certificate.

If you're on Windows(where the certifications aren't included) or don't have or can't update system certifications for whatever reason, then you will have to update rubygems through other means. See https://gist.github.com/luislavena/f064211759ee0f806c88#installing-using-update-packages-new, but get a more recent updated package.

Unfortunately, there really isn't any other way to solve this issue other than updating your system certificates (impossible for typical Windows users), obtaining the new certificate manually, or through a manually updating rubygems.

Edit: Here's a quicklink download to the updated gem: https://rubygems.org/downloads/rubygems-update-2.6.7.gem

Azolo commented Oct 6, 2016

So, the reason why this is happening is because rubygems.org updated their SSL certificate and older versions don't have the updated certificate bundled.

If you're using a traditional OpenSSL distribution then updating it would likely pull in new certificates that include the new rubygems certificate.

If you're on Windows(where the certifications aren't included) or don't have or can't update system certifications for whatever reason, then you will have to update rubygems through other means. See https://gist.github.com/luislavena/f064211759ee0f806c88#installing-using-update-packages-new, but get a more recent updated package.

Unfortunately, there really isn't any other way to solve this issue other than updating your system certificates (impossible for typical Windows users), obtaining the new certificate manually, or through a manually updating rubygems.

Edit: Here's a quicklink download to the updated gem: https://rubygems.org/downloads/rubygems-update-2.6.7.gem

@Azolo Azolo referenced this issue in oneclick/rubyinstaller Oct 6, 2016

Closed

gem installation is broken with an SSL error #338

@PavelEmelyanov

This comment has been minimized.

Show comment
Hide comment
@PavelEmelyanov

PavelEmelyanov Oct 7, 2016

Thank you, manual updating of rubygem helped me.

Thank you, manual updating of rubygem helped me.

@djberg96

This comment has been minimized.

Show comment
Hide comment
@djberg96

djberg96 Nov 20, 2016

Contributor

To followup @wwwbeck's comment, I noticed that rubygems could be persnickety about trailing slashes. If you do gem sources -v, you might see "https://rubygems.org/", in which case you'll need to do gem sources -r https://rubygems.org/.

Contributor

djberg96 commented Nov 20, 2016

To followup @wwwbeck's comment, I noticed that rubygems could be persnickety about trailing slashes. If you do gem sources -v, you might see "https://rubygems.org/", in which case you'll need to do gem sources -r https://rubygems.org/.

@deveth0

This comment has been minimized.

Show comment
Hide comment
@deveth0

deveth0 Nov 21, 2016

I noticed this problem with a fresh installation on windows using the ruby-installer.
Another (imho better workaround) is [REDACTED, instead perform a manual upgrade as described on https://rubygems.org/pages/download]

deveth0 commented Nov 21, 2016

I noticed this problem with a fresh installation on windows using the ruby-installer.
Another (imho better workaround) is [REDACTED, instead perform a manual upgrade as described on https://rubygems.org/pages/download]

@vidavidorra

This comment has been minimized.

Show comment
Hide comment
@vidavidorra

vidavidorra Nov 23, 2016

@deveth0 Worked for me (on Windows 10) using the latest installer for 2.3.1 (x64) from link. And running the commands you suggested.
Thanks a lot.

@deveth0 Worked for me (on Windows 10) using the latest installer for 2.3.1 (x64) from link. And running the commands you suggested.
Thanks a lot.

@sangar

This comment has been minimized.

Show comment
Hide comment
@sangar

sangar Nov 25, 2016

Thanks @deveth0. [REDACTED] gave me

ERROR:  While executing gem ... (Gem::OperationNotSupportedError)
    Not connected to a tty and no default specified

on Windows 10

sangar commented Nov 25, 2016

Thanks @deveth0. [REDACTED] gave me

ERROR:  While executing gem ... (Gem::OperationNotSupportedError)
    Not connected to a tty and no default specified

on Windows 10

@manibk31

This comment has been minimized.

Show comment
Hide comment
@manibk31

manibk31 Nov 27, 2016

The bug is with connection establishment over https. [REDACTED]

manibk31 commented Nov 27, 2016

The bug is with connection establishment over https. [REDACTED]

@medghaim

This comment has been minimized.

Show comment
Hide comment
@medghaim

medghaim Nov 29, 2016

http is unsecure and can leave you vulnerable to a MITM attack

http is unsecure and can leave you vulnerable to a MITM attack

@manibk31

This comment has been minimized.

Show comment
Hide comment
@manibk31

manibk31 Nov 29, 2016

Yes using http over https exposes you to MITM attacks.for local development and testing purposes http can be given a shot. In most of the cloud hosting dependencies installation is taken care by the vendor.

Yes using http over https exposes you to MITM attacks.for local development and testing purposes http can be given a shot. In most of the cloud hosting dependencies installation is taken care by the vendor.

@BastiTee BastiTee referenced this issue in sferik/t Dec 5, 2016

Open

SSL certificate issues #308

@ashmaroli ashmaroli referenced this issue in jekyll/jekyll Dec 6, 2016

Closed

Update Problem #5634

3 of 17 tasks complete
@ferhoba

This comment has been minimized.

Show comment
Hide comment
@ferhoba

ferhoba Dec 6, 2016

Hello shiny happy people,

I have win 10 - 64x

Manual set up instructions on this link solved issue. http://guides.rubygems.org/ssl-certificate-update/#manual-solution-to-ssl-issue

I hope this could help someone

Greetings.

ferhoba commented Dec 6, 2016

Hello shiny happy people,

I have win 10 - 64x

Manual set up instructions on this link solved issue. http://guides.rubygems.org/ssl-certificate-update/#manual-solution-to-ssl-issue

I hope this could help someone

Greetings.

@tristantao

This comment has been minimized.

Show comment
Hide comment
@tristantao

tristantao Dec 27, 2016

I highly recommend people reading this thread as well: #1758 It contained the only solution that worked for me (and I tried many).

I highly recommend people reading this thread as well: #1758 It contained the only solution that worked for me (and I tried many).

@yangshun

This comment has been minimized.

Show comment
Hide comment
@yangshun

yangshun Jan 13, 2017

I simply had to change to ruby-2.3.0 and it installed fine for me.

I simply had to change to ruby-2.3.0 and it installed fine for me.

@cannahum

This comment has been minimized.

Show comment
Hide comment
@cannahum

cannahum May 12, 2017

Updating ruby version (to 2.4.1) worked for me too...

Updating ruby version (to 2.4.1) worked for me too...

@her

This comment has been minimized.

Show comment
Hide comment
@her

her Jun 12, 2017

I think it was an openssl error for me, something about downloading openssl first and then maybe updates breaking somewhere along the way after brew install [pkg] multiple times. I removed openssl, reinstalled, that seemed to have fixed it.

her commented Jun 12, 2017

I think it was an openssl error for me, something about downloading openssl first and then maybe updates breaking somewhere along the way after brew install [pkg] multiple times. I removed openssl, reinstalled, that seemed to have fixed it.

@ashutoshag

This comment has been minimized.

Show comment
Hide comment
@ashutoshag

ashutoshag Jul 27, 2017

The certificate changed. Just run the following command, if you are using OSX:

rvm osx-ssl-certs update all

The certificate changed. Just run the following command, if you are using OSX:

rvm osx-ssl-certs update all

@samoyi samoyi referenced this issue in samoyi/learnGulp Jul 31, 2017

Open

使用 gulp-scss 时出错 #1

@afroguy16

This comment has been minimized.

Show comment
Hide comment
@afroguy16

afroguy16 Aug 29, 2017

Guys read ferhoba's response. Trust me, it works like charm.

image

afroguy16 commented Aug 29, 2017

Guys read ferhoba's response. Trust me, it works like charm.

image

@BharatBabbar28

This comment has been minimized.

Show comment
Hide comment
@BharatBabbar28

BharatBabbar28 Dec 21, 2017

Hi, you should exclude your system from ssl or https scanning first then try
It will work definitely otherwise let me know
bharatbabbar28@gmail.com

Hi, you should exclude your system from ssl or https scanning first then try
It will work definitely otherwise let me know
bharatbabbar28@gmail.com

@falilou13

This comment has been minimized.

Show comment
Hide comment
@falilou13

falilou13 Feb 10, 2018

C:\Windows\system32>gem install rails --no-ri --no-rdoc

C:\Windows\system32>gem install rails --no-ri --no-rdoc
Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 3%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 4%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 3%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 17%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 8%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 15%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 8%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 10%)ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
too many connection resets (https://api.rubygems.org/gems/nokogiri-1.8.2-x64-mingw32.gem)

can't install rails on win 10 x-64 please need help

C:\Windows\system32>gem install rails --no-ri --no-rdoc

C:\Windows\system32>gem install rails --no-ri --no-rdoc
Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 3%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 4%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 3%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 17%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 8%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 15%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 8%)Fetching: nokogiri-1.8.2Fetching: nokogiri-1.8.2-x64-mingw32.gem ( 10%)ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
too many connection resets (https://api.rubygems.org/gems/nokogiri-1.8.2-x64-mingw32.gem)

can't install rails on win 10 x-64 please need help

@ollej

This comment has been minimized.

Show comment
Hide comment
@ollej

ollej Mar 15, 2018

I had this issue, and it turned out the rubygems.org certificate was newer than the time on my vagrant machine. Setting the correct time in the vagrant fixed the issue for me.

ollej commented Mar 15, 2018

I had this issue, and it turned out the rubygems.org certificate was newer than the time on my vagrant machine. Setting the correct time in the vagrant fixed the issue for me.

@rubymorillo rubymorillo referenced this issue in bundler/bundler-site Mar 15, 2018

Merged

Added Vagrant section & fixed jump links #369

bundlerbot added a commit to bundler/bundler-site that referenced this issue Mar 16, 2018

Auto merge of #369 - rubymorillo:master, r=indirect
Added Vagrant section & fixed jump links

Thanks so much for the contribution!
To make reviewing this PR a bit easier, please fill out answers to the following questions.

### What was the end-user problem that led to this PR?

The problem was...
A user reported a possible problem and fix for reconciling their rubygems certificate in vagrant (rubygems/rubygems#1736 (comment)). We wanted to add this to the guide.

Additionally, while testing out the links in staging, I noticed that many of the jump links in the doc weren't properly set, so I made sure the anchor text matched the title of the section.

### What was your diagnosis of the problem?

My diagnosis was...
1. add a possible solution for vagrant users
2. fix the jump links

### What is your fix for the problem, implemented in this PR?

My fix...
see above!

### Why did you choose this fix out of the possible options?

I chose this fix because...
it would help vagrant users access a possible solution && users would actually be able to jump around the doc successfully!
@trentbullard

This comment has been minimized.

Show comment
Hide comment
@trentbullard

trentbullard Apr 19, 2018

I didn't want to update rubygems or any other gem because i'm following a tutorial. I followed the link posted by ferhoba. All i did was download the new cert and save it in my ssl_certs folder and i was able to install everything fine.

I didn't want to update rubygems or any other gem because i'm following a tutorial. I followed the link posted by ferhoba. All i did was download the new cert and save it in my ssl_certs folder and i was able to install everything fine.

@xpagesbeast

This comment has been minimized.

Show comment
Hide comment
@xpagesbeast

xpagesbeast Jun 5, 2018

I was running Ruby22x64 and experienced the SSL error. Used the installer Ruby+Devkit 2.4.X https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.4.4-1/rubyinstaller-devkit-2.4.4-1-x64.exe and tried again with success.

xpagesbeast commented Jun 5, 2018

I was running Ruby22x64 and experienced the SSL error. Used the installer Ruby+Devkit 2.4.X https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.4.4-1/rubyinstaller-devkit-2.4.4-1-x64.exe and tried again with success.

@fayaj1

This comment has been minimized.

Show comment
Hide comment
@fayaj1

fayaj1 Jul 11, 2018

If i install the COCOAPODS it will showing this ERROR MESSAGE

ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: tlsv1 alert protocol version (https://rubygems.org/latest_specs.4.8.gz)

How to Fix it??

fayaj1 commented Jul 11, 2018

If i install the COCOAPODS it will showing this ERROR MESSAGE

ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: tlsv1 alert protocol version (https://rubygems.org/latest_specs.4.8.gz)

How to Fix it??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment