Create a gist now

Instantly share code, notes, and snippets.

Workaround RubyGems' SSL errors on Ruby for Windows (RubyInstaller)

SSL upgrades on rubygems.org and RubyInstaller versions

UPDATE 2016-12-01: Please refer to the official guide instead of this process.

UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.


Hello,

If you reached this page, means you've hit this SSL error when trying to pull updates from RubyGems:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

This error is produced by changes in rubygems.org infrastructure, please keep reading to better understand it.

If you're one of those too long, didn't read just skip to the guide on how to workaround it.

Background

For those who are not familiar with SSL and certificates, there are many parts that make secure serving of content possible.

SSL certificates are used on the website, which are obtained from a certificate authority (CA) and generated from a private key, along with its respective signature.

Normally and up until a few months ago, private key signatures used SHA-1 as way to provide a digest (or checksum) of the private key without distributing the key itself (remember, needs to remain private).

SHA-1 has been encountered weak and lot of web servers and sites have been upgrading towards SHA-2 (specifically SHA256 or higher) in order to prepare for the browsers changes.

Specific problem with RubyGems

The particular case of RubyGems (the command line tool) is that it requires to bundle inside of its code the trust certificates, which allow RubyGems to establish a connection with the servers even when base operating system is unable to verify the identity of them.

Up until a few months ago, this certificate was provided by one CA, but newer certificate is provided by a different one.

Because of this, existing installations of RubyGems would have to been updated before the switch of the certificate and give enough time for the change to spread (and people to update).

As what normally happens with software, things might get out of sync and coordinate such effort, to the size and usage of rubygems.org is almost impossible.

I've described this on Issue #1050

We had discussed also on IRC, and patches and backports were provided to all major branches of RubyGems: 1.8, 2.0, 2.2, 2.4 and 2.6

Please understand this could happen to anyone. Release multiple versions of any software in a short span of time and be very time sensitive is highly complicated.

Even if we have official releases of any of the versions that correct the issue, it will not be possible install those via RubyGems (chicken-egg problem described before).

Installing using update packages

RubyGems has covered this in the official guides, please follow the instructions here

It involves:

  • Manually downloading the latest .gem file.
  • Installing it using gem install --local
  • Run the update_rubygems command
  • Profit

You should now be able to install gems normally.

If you still experience any issue, please search for any existing issue on RubyGems Issue Tracker or report a new one.

@drbrain
drbrain commented Dec 2, 2014

I think we should add this to guides.rubygems.org

@takueof
takueof commented Dec 3, 2014

+1

@trabulmonkee

Thanks for the insight and workaround. Just tried it out and gem installs are working now.
ruby -v
ruby 2.0.0p598 (2014-11-13) [i386-mingw32]
gem -v
2.4.5

@StevieJayCee

You sir, are a 'gem'. Thanks muchly.

@codeodor
codeodor commented Dec 3, 2014

Thank you for this. Big help. ❀️ πŸ’š πŸ’œ

@luislavena
Owner

@trabulmonkee please avoid RubyGems 2.4.x, as mentioned in the instructions, that version is broken on Windows.

@beauxjames

Thank you...where do I send the beer?

@brunowego

Thanks @luislavena πŸ˜„

@jomko
jomko commented Dec 4, 2014

thank you!

@bdonaldharris

THANK YOU!!!!!!!!!!!

@tsanak
tsanak commented Dec 7, 2014

Thank you so much!! πŸ˜ƒ πŸ˜„

@rroman81
rroman81 commented Dec 9, 2014

great stuff, boy. This is definitely needs to be added to the guide.
Btw, how do i update the documentation of the already installed gems. I had to use --source http://api.rubygems.org option to get some gems while experiencing this issue.

@rmorrin
rmorrin commented Dec 10, 2014

Awesome stuff, fixed the issue for me too! πŸ‘

@voku
voku commented Dec 10, 2014

Thx for this +1

@TImPDaley

THANK YOU VERY MUCH...

@jltemple

+1, +1 for adding this to the guide

@perfmoron

Naice job!

@robert-toth

Works like a charm. Thanks!

@jdonaldson10

Thanks πŸ‘

@vtypal
vtypal commented Dec 13, 2014

Thank you

@nakoo
nakoo commented Dec 13, 2014

Thanks!

@st0le
st0le commented Dec 14, 2014

+1

@dlwilson88

Yet another happy coder

@gmarini
gmarini commented Dec 16, 2014

Thanks! It works!

@PeterCamilleri

Heart filled gratitude and thanks!

@master777

Thanks!!

@ferventcoder

πŸ‘

@tangorri

Thanks a lot !

@cusnar
cusnar commented Dec 17, 2014

Works great! Thanks!

@kastuart

Sweet baby jesus it works! You're the best!

@jethroo
jethroo commented Dec 18, 2014

awesome 🍸

@RichardHorton

Thank you!

@poleveD
poleveD commented Dec 18, 2014

Saved me lots of pain! Thank you!!

@datacoda

Thank you.

@omarsar
omarsar commented Dec 18, 2014

Worked great. Thanks for the fix!

@BenCrook

Thank you!

@EtaiG
EtaiG commented Dec 19, 2014

Thanks - this is exactly what I needed.

Thank you also for the well written explanation!

@sharavsambuu

cool! it work like a charm

@jjgh
jjgh commented Dec 20, 2014

Thanks. For some reason it was not working to me on Win7-64 until I added the "SSL_CERT_FILE" env. var with:

C:\set SSL_CERT_FILE=C:\Ruby200-x64\lib\ruby\2.0.0\rubygems\ssl_certs\AddTrustExternalCARoot-2048.pem

On a side-side-side note I'm experiencing the usual infinite CPU hog while installing rubygems darkfish documentation. This has been reported many times (at least on windows) and happens now and then with any gems... just a reminder in case someone wants something to work on ;)

@luislavena
Owner

Folks,

I've updated the gist to include instructions on how to manually upgrade using the released update packages.

Cheers.

@thany
thany commented Dec 21, 2014

Works.

Now the guys at ruby can go an incorporate this into the installer. It's quite rediculous to have to do this for every new Ruby installation.

@hmurillop

Thank you so much!! i have used the Manual solution to SSL issue and it worked great!!

@architrathi

A big thank you! Took a lot of time to find this thread.

@krisimmig

thumbs up!

@chiefy
chiefy commented Dec 22, 2014

πŸ‘ Windows 8.1 x64 ruby 2.0.0p481 mingw

@ghost
ghost commented Dec 22, 2014

Works perfectly on Windows 7 x64 with Ruby 2.1.5p273 (2014-11-13 revision 48405) [x64-mingw32]
Thank you so much!

@Eaiman
Eaiman commented Dec 24, 2014

It works.
Thank you so much :)

@ClementNerma

Thank you very much !!!! πŸ˜„

@miau
miau commented Dec 25, 2014

I've written a dirty one-liner that do steps of "Manual solution to SSL issue". It works on Windows.
https://gist.github.com/miau/1b9eb877acb57f6c4c58

@jtlindsey

Thanks, installing using update package (new) worked for me on Win7 pro

@Alex-Fortin

Thanks so much. great explanation

@mikeoconnell

Thanks for this! Back to my tutorials...

@dunake
dunake commented Dec 29, 2014

thank you so much

@menz1es
menz1es commented Dec 29, 2014

@miau your the man, that beast of a one-liner worked a treat.

@krestt
krestt commented Dec 30, 2014

You are the Man!! Thank you very much!

@prideloki

thank you

@benmathews1

Hi! I'm really really new to coding in general and pretty much everything specifically and I was following the lynda.com tutorial regarding installing Ruby on Rails until I encountered this error. Unfortunately, though I tried several times to apply the above fix, I'm still stuck! For one thing, when I click the link for the trust certificate I get a big block of text, which I think is correct, but I'm not sure how to "download" this or place it anywhere. And then in step two, when I do the "locat[ing] the directory" step a little window does appear, but it vanishes almost immediately. Past that I don't really know what to do? I've tried pasting the trust certificate text directly in the command prompt box deal, which didn't work, and I've tried opening that vanishing window again and again but it just disappears over and over. Again, I have no clue what I'm doing and I'm sure I'm making some huge ookie mistake but any advice would be greatly appreciated!! Thanks!!!

@ghost
ghost commented Jan 3, 2015

THANK YOU!

@mctolentino

Works perfectly! Thanks for the workaround.

@trabulmonkee

@luislavena - So updating to rubygems 2.4.x after doing this manual update is not advised, should just stay at 2.0.15? My understanding was that it was just a cert key issue which gets resolved after doing the manual update.

@nagoshiashumari

Thank you for this. :+1

@newbro
newbro commented Jan 6, 2015

Another thank you from me :D

@GeetaGh
GeetaGh commented Jan 6, 2015

Thank you..

@GeetaGh
GeetaGh commented Jan 6, 2015

Surprisingly when I installed compass for the first time, i didn't have to do anything , but while upgrading I was facing this issue. And I was completely going in wrong way, until I was your post. Thank you.

@DuongAnh
DuongAnh commented Jan 6, 2015

Thanks for your help ! PERFECT ^_^

@bjbussell

Thanks!

@lostandfownd

Tnx , solved the problem instantly , best fix on the web

@intuedge
intuedge commented Jan 7, 2015

@benmathews1 -- don't click the link to open it. right-click and select save-as, and then follow the guidelines to make sure that the file you save ends up with the proper .pem extension.

@neoalvaro

Luis I got stuck in step 3 of "Manual Solution", how can I locate ssl_certs directory and copy the .pem file? on a pc windows 8? I'm a total newbie in all this programing field. thanks

@mmm13
mmm13 commented Jan 8, 2015

Thanks! working now..

@MikaelSmith

Thank you so much for your work on this.

@obiora22
obiora22 commented Jan 9, 2015

Awesome help. Thank you!!!

@circleupx

Perfect πŸ˜„

@webdevilopers

πŸ‘

@TobiasAxelsson

Thanks for your work on this, had problems for days but thought it was my firewall or network.
For some reason the folder is protected (win7 64 admin-rights) and the commands fail. But the manual operation worked. Thanks again!

@Limess
Limess commented Jan 11, 2015

Worked for me, thank you.

@dmitryvmin

Fixed. Thank you!

@dniman
dniman commented Jan 15, 2015

Great job! Thanks!

@sterswift

thanks, man, you saved my ass

@anicething

thans,man,you saved my ass

@gabridoga

Thanks for your help.
This issue is very useful for ROR install on windows 7.
Again say "Thanks for your help luislavena! Great ,Perfectly "

@dongchen

Thank you. This worked for me.

@jfloff
jfloff commented Jan 20, 2015

πŸ‘

@yubrajpokharel

thats great thanks a lot

@cfetty
cfetty commented Jan 21, 2015

Clarification on step 2. Simply copy the new cert file to the cert directory under Ruby. For example mine was under C:\Ruby21-x64\lib\ruby\2.1.0\rubygems\ssl_certs

@UdayKumarDas

Thank you very much, it's really helpfull

@kyusufm
kyusufm commented Jan 23, 2015

Thank you so much, it's really help.

@levserk
levserk commented Jan 23, 2015

Thank you so much!

@yaooluu
yaooluu commented Jan 24, 2015

Thank you sir! Nothing can express my gratitude for your article. Thank you!!!

@watersavvy

Thank you! I had to do a small modification to the process by downloading 2.2.3, then pulling the SSL Cert from that file and placing it into the original Ruby DL pack.

@vike27
vike27 commented Jan 26, 2015

Thank you!!!! Finally I can get back to coding!

@alkinkasap

all i can say is, That's Great! thank you..

@stephendanner

Awesome! Worked perfectly on my Windoze 7 system. Thanks. Now I can get back to the Ruby on Rails intro.

@fanian
fanian commented Jan 28, 2015

Amazing! Thanks for your participation!

@valgreen01

Thanks a lot! it works πŸ˜€

@fikriauliya

Thanks it works πŸ‘

@gatilin222

Very helpful, thanks

@SleepWalker

Thanks a lot! rubygems-update worked for me

@cobyasante

This should be part of the manual, in fact it should the first thing you see before you start going about installing ruby or rails
Thanks guys you have saved me a lot of headaches

@aoeasif
aoeasif commented Jan 31, 2015

Thanks it's works fine. πŸ˜„ :

@ifkas
ifkas commented Feb 1, 2015

Beautiful, works as a charm, thanks bunch!

@Landish
Landish commented Feb 2, 2015

I can't believe this. It finally works.
Many thanks to you @luislavena, you're my hero 😊

@ShulinChen

Thanks you so much!!!! After almost 2 hours of trying all kinds of technique, this one finally works!!Couldnt be more thankful

@chebaby
chebaby commented Feb 3, 2015

thank you @luislavena, it works

@charlesuko

thanks so much. this worked perfectly

@rezadehganpour

Hey Luis Thank you very much for this, However I followed all of your steps and still I have the certification problem my gem version was: 2.2.2 and with your help I upgrade that to 2.2.3. my "gem which rubygems" command return C:ror/Ruby200/lib/ruby/site_ruby/2.1.0/rubygems.rm.
When I tried to copy the .pem file that you provide in the ssl_certs file the name of the file was already exist so I replaced it! I just want to be as specific as I can so you can help me with this better!

Thanks a million!

@anisabboud

Thank you!

@KabbAmine

Thank you very much πŸ˜„

@kspurgin
kspurgin commented Feb 9, 2015

++ thanks.

@MattForerunner

I must be really bad with computers or something but I can not get this to work for the life of me!

@MattForerunner

Thank you JESUS I GOT IT TO WORK!!!!

@sweco-seprst

Is this suppose to also work on mac? I can't get it to work.

@prasanthkarukkuvel

Saved my day! Thank you 😊

@anilpanthi

thanks bro

@mrwhitney

Downloaded rubygems-update-2.2.3.gem from https://github.com/rubygems/rubygems/releases/tag/v2.2.3

gem install --local ubygems-update-2.2.3.gem
#  Successfully installed rubygems-update-2.2.3

gem --version
#2.2.2

Using Git bash on Windows 7.

Edit: I missed

update_rubygems --no-ri --no-rdoc
@nipendar

Thank you...very nice explanation

@ghost
ghost commented Feb 16, 2015

Thank you very much, now I'm able to start with SASS πŸ˜‚

@MickCreates

This is perfect! It solved my dilemma, I thought I was going mad running around in circles trying to get a few simple gems installed but this really did the trick.

Thank you!

@Sailaja13

Thanks a lot!

@Andrelton

THANK YOU!

@realjimmyli

Thanks very much!!!!!!!!!!!!!!

@rashmibmanyam

I followed all the steps that you have mentioned, but I still see the same error. :(

@DerekFoulk

My god. Now I can use Jekyll to build my Bootstrap. Thank you. Thank you thank you thank (a million times) thank you. This worked like a charm...

@mawwerik

Thanks for this excellent description...

@RomainBrunias

Thanks.

@harellevy

Thanks!!! that helped me!!

@akshitshah

helped!!! rockstar you are!!!

@jansmolders86

Thanks a bunch! πŸ‘

@diazemiliano

Thanks! πŸ‘Œ

@dynamite-ready

Can't you just add the cert to the latest installation packages, and shorten the guide above?

@hpasweden

Works fine! thx

@rubiconTwist

Thank you!

@SHenry77

Thank you, I was at a loss. You got me back on track.

@abdullahnaseer

Thank you!

@purduekenny

You're the best.

@satphonix

Thanks, it works!

@rezwan-hossain

thank u its work

@wellxion
wellxion commented Mar 2, 2015

thx a lot. It's useful

@ghost
ghost commented Mar 3, 2015

+1 +1

@lenazh
lenazh commented Mar 3, 2015

Thank you so much!!! I hurt my head bashing it against a wall already!

@acaparrelli

thank you man!

@mohamedahmed3ali

Thanks so much

@server102

+1... Thanks alot

@davewallace

+1 much appreciated.

@ghost
ghost commented Mar 4, 2015

To you sir, I am so very grateful. It is much appreciated. +1

@HACKVTT
HACKVTT commented Mar 4, 2015

Thanks, It's work for me (y)

@vegas0250

Thanks.

@richpeck
richpeck commented Mar 4, 2015

Thank you so much - worked a treat

@chesiljuanich

Thank you so much !
What a big help , it works :)

@widiarifki

yep, it works.

@Kcko
Kcko commented Mar 5, 2015

Its work 4 me. Thanx for sharing!

@pzurawski83

awsome!!! thanks a lot

@mtrojanowski

Thanks! πŸ‘

@thomthom
thomthom commented Mar 7, 2015

Thank you very much for this detailed description and solution. πŸ‘

@brunabxs
brunabxs commented Mar 7, 2015

Thanks a lot!

@vlrprbttst

thaaaaaaaaanks

@euccas
euccas commented Mar 10, 2015

works perfectly. +1 thanks.

@saaqibz
saaqibz commented Mar 11, 2015

worked like a charm. Thanks

@ch0pch0p

I'm still having problems with this...I've followed the instructions exactly and I'm still getting this (https://gist.github.com/ptulip/4c4358c8fad58f757eed) sort of error.

Any help would be much appreciated. Win7-64, ruby 2.1.5, rubygems 2.2.3

Example code I'm trying to run:

require 'open-uri'
gg = open('https://gg.com')
puts gg

@devhut
devhut commented Mar 13, 2015

luis for president!

@andersonanderson

Still Working!!! Thanks luislavena

@rbtsolis

Thank Youuuuu, Gracias me sirvio mil, ya puedo instalar la gema rhc de OpenShift, es genial πŸ˜„

@mikerentas

Thank you! Excellent walkthrough, and it worked perfectly!

@KrzyKuStudio

Updating gems 2.2.2 worked for me. Thank you

@nathanvda

Awesome, thanks for the help! I develop on mac and deploy on windows servers, so now I can still use https://rubygems.org as the source. I recently added https://rails-assets.org because it is an incredibly easy way to include bower packages in a rails project. However: this does work on mac, but gives me the same SSL error on windows.

I installed the 2.2.3 gem. I am not sure if this is relevant or not (like: maybe it deleted the old certificate?)

Am I correct in assuming any gem-server's certificate needs to be included in the rubygems package? I am guessing they are not using the same root certificate, or it should just work. So any idea where I can find the certificate for rails-assets.org?

For now i just use http://rails-assets.org as source as a workaround.

@helloncanella

Ow. Wonderful. My Christmas Gift was already brought! πŸ˜„

@thetypebeast

Tried the manual install since I have RubyGems version 2.4.x. After testing with gem install json --platform=ruby I'm still getting ERROR: Could not find a valid gem 'json' (>= 0), here is why: Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read serve r certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

I can verify that the certificate exists in ssl_certs, and is definitely .pem file format.
I'm only using one version of ruby. So what now?

Edit: I did read the entire background and problem, but I might be missing something, since i'm just a designer trying to set this stuff up on a Windows machine so I create my prototypes using Sass, etc.

Windows 7 pro
Ruby 2.2.1p85
RubyGems 2.4.6

@phongkien

very nice, thanks!

@logos9000

Thank you! Nice, detailed instructions. Worked perfectly for RubyGems 2.0.14 -> 2.0.15.

@vongoh
vongoh commented Mar 25, 2015

Thanks! Did the trick.

Suggestion: you gave instructions under 'Installing using update packages (NEW)'.

Then right under that you gave the instructions for a Manual Install. At first glance it was confusing and made it seem like we also had to do that as well --- you might want to consider re-wording that so it is more clear to people that are simply trying to straighten this out

@maxpower720

Thanks! That did the trick!

@DeeBaker

Thank you much. Love the way you write with humor.

@TheNaoX
TheNaoX commented Mar 28, 2015

Β‘A huevo! πŸ‘
Thank you so much!

@alecperkey

For anyone who is having issues, in particular on 1.9.3 (but maybe others too):

When you do the command 'gem which rubygems'
There are two locations which I happened to mix up

C:\Ruby193\lib\ruby\1.9.1\rubygems\ssl_certs <-- incorrect
C:\Ruby193\lib\ruby\site_ruby\1.9.1\rubygems\ssl_certs <-- correct

Best,
Alec

@JimiofEden

Similar to @alecperkey, I am on ruby 2.0.0, and I had to put the ssl_certificate in:

C:\Ruby200\lib\ruby\site_ruby\2.0.0\rubygems\ssl_certs

@wilfred05777

Wow! this make my day ! thank you for sharing!

@jumpluff
jumpluff commented Apr 5, 2015

Thank you so much for both the background information and the clear tutorial.

@JTallis
JTallis commented Apr 9, 2015

Amazing, thanks!

@bk2git
bk2git commented Apr 9, 2015

The solution worked for me with Ruby 1.9.3 on 32 bit Windows 7, but not with Ruby 2.2.0 on 64-bit Windows 8.1 Enterprise.

Rubygems: C:/Ruby22-x64/lib/ruby/2.2.0/rubygems.rb

I put AddTrustExternalCARoot-2048.pem in both C:\Ruby22-x64\lib\ruby\2.2.0\rubygems\ssl_certs and C:\Ruby22-x64\lib\ruby\site_ruby\2.2.0\rubygems\ssl_certs.

@kevinarrieta

Thanks!

@mikebsg01

Eres la leche amigo! Muchas Gracias πŸ˜ƒ

@stickerboy

Great write up, thanks! :)

@bk2git
bk2git commented Apr 14, 2015

Thank you. It worked for me with an older installation of Ruby. But with a new installation of Ruby on a new machine I am having this issue:

Steps: (1) Install Ruby 2.2.1 on Windows 7 x64. (2) Verify "gem --version" returns 2.4.5 (3) Verify "gem which rubygems" returns "C:/Ruby22/lib/ruby/2.2.0/rubygems.rb". (4) In Explorer, go to C:\Ruby22\lib\ruby\2.2.0\rubygems\ssl_certs. (5) Verify that "AddTrustExternalCARoot-2048.pem" already exists and that the content is the same as the content of the pem certificate in this web page's hyperlink. (6) Verify still unable to install a gem and get the SSL error. (7) Overlay the existing pem file with the pem certificate in the hyperlink of this webpage. (8) Verify gem installation returns "ERROR: While executing gem ... (OpenSSL::X509::StoreError)".

@Mikey-Lee

nice one !

@meysammeisam

the same issue as @bk2git (2 comments upper) :

ubuntu 12.04 32bit,
gem --version => "2.4.5"
gem which rubygems => ".rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems.rb"
...

@iconcells

copy the .pem file actually solved the problem. Wonder why that was not being fixed in the installer in the first place for Windows. Thanks a lot.

@mlb5000
mlb5000 commented Apr 27, 2015

.pem file workout does not work for RubyInstaller - Ruby 2.2.2 x64 - Windows 8.1

ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]

gem --version
2.4.5

Even downloading the latest rubygems gem and installing it doesn't work.

@mlb5000
mlb5000 commented Apr 27, 2015

Same problem with 2.1.6 32-bit.

@osdk
osdk commented Apr 29, 2015

It solved my problem... thanks

@MattCordell

Thankyou. This is my first foray into Ruby, and you saved me a lot of pain.

@BahiHussein

Thank You. saved my day

@bk2git
bk2git commented May 7, 2015

@mlb5000. See same problem. Could the cause be related to 64-bit Windows OS? I see the problem on Windows 7 b4 bit and Windows 8.1 64 bit. I do not see the problem on Windows 7 32 bit.

@gaurav-lad

Thank you. luislavena

@raoprashanth007

Thanks, It worked for me too

@StevenBR

Worked here on windows 10 tech 64-bit. Thank you!

@flightofthunder

Worked on Windows 7 64-bit. Fantastic, thank you very much

@saske505

Thanks you so much, windows 7 32bit

@TomDeFrank

Windows 8.fix not working.
.pem file wad already present in ssl folder

@varundmishra

@TomDeFrank : You are right, the fix ain't working for Windows 8.1 64 bit (Ruby 2.2.x)
Try uninstalling 2.2.x and install 2.1.6 (32 bit) with relevant DevKit, works for me.

@nollenr
nollenr commented May 20, 2015

Fix not working for Linux (Centos 2.6.32-504.16.2.el6.i686)
[root@renoir ssl_certs]# ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [i686-linux]
[root@renoir ssl_certs]# gem -v
2.4.7

AddTrustExternalCARoot-2048.pem is current and matches

@linf2
linf2 commented May 23, 2015

Omg thank you.

@moicarolyn

Thank you!!!!

@DenisLemos

Thank you sir. You are a gentlemen and a scholar ΰ² _ರೃ

@fernandoGN

In my case the solution was to use the proxy:

gem install --http-proxy http://ip:port jekyll
@patrickst1

Excellent, Thank you!!

@Bela2711
Bela2711 commented Jun 6, 2015

Thanks, it helped! :)

@abbondanza

Great stuff! Truly helpful.. Will share with others where I work

@Visionaire

Thank you, that was helpfull and right to the point! 😊

@prinok7
prinok7 commented Jun 14, 2015

Respect Man! you really are one BIG Gem of a guru! it worked !!! been labouring for days now,until you showed up.thanks a million.keep up the good work and more gems to your fingers and brain!

@wyrdathru

For those having issues on Windows 8.1 64-bit, try https://gist.github.com/fnichol/867550.

You'll need to uninstall Ruby 2.2 (or whatever) from Control Panel and download the RailsInstaller package, then follow the steps outlined.

Make sure you add your environment variable, not just use 'set' from the command line.

@dapperAuteur

you're my new favorite developer. I wonder what your rookie card is worth!?

@ArsenalofCode

you are possibly the greatest human i have ever encountered on the internet world.

thank you.

@evanweking

thanks you very much,,, one more thing,, is installing gems rails is taking a long time or not?? thank you

@GuinetPro

MUCHAS GRACIAS!!!!!

@compajl50

Thank you for explaining background is very helpful. Having old installations of gems and rails on Windows 64bit machines.

@taragano

Amazing! Thank you :)

@A-Nasser

Thanks a lot, working gr8.

@fschwiet
fschwiet commented Jul 1, 2015

I had a different issue, using Vagrant on Windows it turns out a recent change to the ffi gem causes problems that report the same problem (SSL cert failed). In case others are in the same boat, I thought I'd link the solution that finally worked for me (installing vagrant plugin ffi version 1.9.8) at: http://stackoverflow.com/questions/31106397/first-vagrant-up-works-but-then-ruby-error-after-halt-up/31121287#31121287

@helltone
helltone commented Jul 2, 2015

done it!

@realvjy
realvjy commented Jul 6, 2015

It works.
Thanks !!

@hunj
hunj commented Jul 9, 2015

It works!
Thank you :)

@paratagas

Thank you, man, great explanation!

@haryantowang09

This is super amazing ! I tried the manual way, works like guessing 1+1 = 2.

@antoniomerlin

ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]
gem -v : 2.3.0
Rails 4.2.3

I've tried the above steps but getting following issue Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/minit est-5.7.0.gem) An error occurred while installing minitest (5.7.0), and Bundler cannot continue. Make sure that `gem install minitest -v '5.7.0'` succeeds before bundling.

@LucasServare

Exactly what I was looking for, thank you very much!

@thepulkitagarwal

Worked like a charm! Thank You :)

@coirewalker

In this section:
==== Installing using update packages (NEW) ===

I am stuck. In the last step (the uninstall) I received the following prompt, not in this tutorial:
$ gem uninstall rubygems-update
Remove executables:
update_rubygems

in addition to the gem? [Yn] n
Executables and scripts will remain installed.
Successfully uninstalled rubygems-update-2.2.3
$ gem uninstall rubygems-update
$ "

There is a blank prompt on this last line, so if I was supposed to enter "Y" there doesn't seem to be way to do so. Sorry if I missed something obvious--I'm new to this stuff and been at it for 10hrs straight now haha.

Please advise. Thanks.

@eyecatchup

There's one more solution which is actually the easiest and will work 100%: change the default source from https:// to http://. (Of course, this is not the recommended solution.)

See: https://gist.github.com/eyecatchup/20a494dff3094059d71d#solution-1-change-default-source-host-from-https-to-http

@parthibd

I encountered this error initially when installing the Ruby 2.0 version of railsinstaller . After doing a "gem update --system" everything is working as it should .

@joncepeda

saves my time! πŸ‘

@felnder7

Thanks a lot !!!!!!!! :-)

@dfmedrano

I've tried all that is written in this gist but I still have the same error. I cannot update or install gems. Any Ideas?
Initially I had rubygems version 2.4.6, I downgraded to 2.2.3 so when I type gem --version I get 2.2.3
My Ruby version is 1.9.3p237
I copied and pasted the certificate file manually but I still get the error
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certif
icate verify failed (https://rubygems.global.ssl.fastly.net/specs.4.8.gz)

Any ideas will be greatly appreciated!

@tonkec
tonkec commented Aug 26, 2015

Finally a solution! Thank you πŸ‘

@wlawbr
wlawbr commented Aug 27, 2015

FWIW this solution will also need to be applied for those behind proxies that do SSL Decrypt (aka Man In The Middle).

The reason for this is that of the requests that are made, two use the TLS SNI headers, but there are two that are made to the CDN that do not include the SNI headers. As a result this makes it really hard to put in MITM bypasses - rubygems.org, api.rubygems.org, and rubygems.global.ssl.fastly.net are already listed and work fine. As a CDN is in use, admins can't just go putting in blocks of IP's to the bypass lists as other content would then be excepted as well.

Just place the proxy's root CA cert in the ssl_certs directory and off you go.

For reference, those using ChefDK 0.7.0 the directory is here:
/opt/chefdk/embedded/lib/ruby/site_ruby/2.1.0/rubygems/ssl_certs

@KhanMaytok

Many thanks!

@irkanu
irkanu commented Aug 28, 2015

+1

@tibsar
tibsar commented Aug 29, 2015

Thank you!

@DanM2010
DanM2010 commented Sep 4, 2015

Thank you!

@shashwat51

Thanks a ton

@salihozd
salihozd commented Sep 6, 2015

Thank you, "Installing using update packages" worked for me.

@mcmonkeys1

Woo! Thanks you!

@mikapa
mikapa commented Sep 13, 2015

+1 from me, too! Thanks!

@ghost
ghost commented Sep 15, 2015

+1 This page is a life server!

@czujnik81

+1 Thanks Man - it saved me lot's of time! Great job

@LAGRANJ
LAGRANJ commented Sep 18, 2015

thanks!

@BWoodfork

I ran into the issue of the listed rubygem-update gem files in this gist, being older than the version that I was running. Below is the link to the newest versions.

The .gem file's for the latest versions of rubygems-update can be found here: https://rubygems.org/gems/rubygems-update/versions

@jhabib
jhabib commented Sep 20, 2015

Thank you!

@gevorgdavoyan

Thank you very much! Everything is working fine now.

@TaylorHuston

Kind of random. I did this workaround a while ago, works great, can still install and update gems all day long.

Except for one project. It's a JekyllRB project, not a Rails one, but it has a Gemfile and I am getting the SSL error from with it. All other projects on my machine seem to be working fine.

jekyll/jekyll#3985

@Seytom
Seytom commented Sep 24, 2015

Was going to save the .pem file in my rubygems/sslcertificates folder, but it was already there. Not the answer for me, unfortunately.

@zayro
zayro commented Sep 28, 2015

Oye Gracias muy Bueno

@ghost
ghost commented Sep 29, 2015

It worked. Thaks. But i got 2.1.5 version of Ruby, is it applicable for the course?

@lumagm
lumagm commented Sep 29, 2015

awesome 🍸

@RajeshGawade

Thank You !

@surbey
surbey commented Oct 8, 2015

Thank you

@rakeshravipati

Thank you

@JirongOTPP

I am new to Ruby but just need to run this: https://github.com/github/platform-samples/blob/master/api/ruby/team_audit.rb.

Can anyone help me get this running?
Thanks
Jirong

C:\OTPPB2015\Workspace\Ruby>dir
Directory of C:\OTPPB2015\Workspace\Ruby

10/09/2015 01:20 PM

.
10/09/2015 01:20 PM ..
10/09/2015 11:07 AM 18 hello.rb
10/09/2015 12:58 PM octokit
09/24/2015 09:35 AM 2,182 octokit.rb
10/09/2015 12:57 PM 2,447 team_audit.rb
3 File(s) 4,647 bytes
3 Dir(s) 273,722,306,560 bytes free

C:\OTPPB2015\Workspace\Ruby>ruby team_audit.rb
C:/Tools/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- octokit/client (LoadError) from C:/Tools/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
from C:/OTPPB2015/Workspace/Ruby/octokit.rb:1:in <top (required)>' from team_audit.rb:13:inrequire_relative'
from team_audit.rb:13:in `

'
C:\OTPPB2015\Workspace\Ruby>

C:\Users\huj\Desktop>ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x64-mingw32]

C:\Users\huj\Desktop>gem -v
2.4.5.1

C:\Users\huj\Desktop>gem install octokit
ERROR: Could not find a valid gem 'octokit' (>= 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/specs.4.8.gz)

@Inhee-LEE

Great. many thanks~! I think that a newbie to Ruby should check this first before Rails installation.

@blindacai

Thank you! I believe it will work

@Beatt
Beatt commented Oct 11, 2015

Thanks dude!

@hujirong

I can run "gem install octokit" at a home pc without any issue, but always get this ssl cert error at a company pc, no matter which version I use and this solution also doesn't help.

@doctopus219

Try updating your gem sources:

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem update --system

@kabirul1990

Cool Buddy.........Its amazing!

@mikerumawas

Hi Luislavena,
Thank you very much for this tutorial.
It helps solved my rails updating issue.

Cheers

@LordWagga

Magic Darts. I cannot say thank you enough.

The more this becomes visible the better. Boomshanka

@enk4
enk4 commented Oct 21, 2015

thanks!

help me solved 'bundle install' things

@cuong2k
cuong2k commented Oct 22, 2015

Hi Luislavena,

support case bundle install fluentd error (centos 6.7 64bit):
bundle install

Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for
all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.4.2

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/cool.io-1.4.1.gem)

[root@localhost ]# ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
[root@localhost ]# gem -v
2.2.3

help me solved !
Thanks ,

@krish8764

Thanks a lot buddy ..

@mcgfv
mcgfv commented Oct 22, 2015

THANKSSSSS!!!! Finally it works!!!!! HURRAAA!!!

@dinghenn1996

I LOVE YOU SIR! THANKS!

@andsild
andsild commented Oct 30, 2015

Another thanks from me :)

@raphaklaus

Worked great on Windows 10. Thanks.

@AndyRockChen

Thank you so much! Nice going.

@tatthien
tatthien commented Nov 9, 2015

Awesome! It works like a charm

@Rushell
Rushell commented Nov 9, 2015

Smoooth ;)
Thanks a lot. πŸ‘

@aporrasp

Excelent!!! Thanks you so much!!!

@chrisbean33

got all the way through, then tried the 'gem install sass' again and got the SSL same error again!.. I am using a Citrix VM machine with Windows 7, would this be an issue?

@Stargator

@chrisbean33, I'm with you. I have Windows 7, RubyGems 2.4.5.1, and Ruby 2.2.3p173 (2015-08-18 revision 51636) [x64-mingw32].

The problem still persists for me.

Correction: @doctopus219's suggestion helped me resolve the issue, though I am connecting without a secure connection.

@bravepurple

Thank you!

@grrrrinaldi

Nice one, thanks - a big help.

@RomanZyev

Thank you! +1

@DeathEmpire

gracias !!

@amitgogte

Thanks !!

@harshad26

I am facing same error when tried to payment SagePay Gateway
Error: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Anybody have idea?

@horror
horror commented Nov 26, 2015

now im your slave! thx!

@Menniti
Menniti commented Nov 29, 2015

Yeah, you are rock! thanks!

@thanh-ng

It works like a charm. Thank you!

@kaanalpyay

Thank you so much :'))))))

@lenhoy
lenhoy commented Dec 9, 2015

My only experience with rails is from codeacademy, and even I managed to do this workaround! Great guide!

@muntasir2165

thanks!

@RSchul2
RSchul2 commented Dec 16, 2015

thank you!

@yadoik
yadoik commented Dec 18, 2015

Diddlehh!

@veevax
veevax commented Dec 21, 2015

Merci!

@Aravin
Aravin commented Dec 23, 2015

Useful Info :)

@krishta
krishta commented Dec 25, 2015

Thanks πŸ‘

@Moutaouakil

Simply +1 πŸ‘

@akmalazlanjamal

Thanks. Love the solution. It works.

@mycql
mycql commented Jan 5, 2016

Worked flawlessly with ruby on mingw. Thanks!

@mehranattari

It worked, Bundle of thanx πŸ‘ :)

@xal0do0x
xal0do0x commented Jan 8, 2016

Thanks you very much! You are a real gem :)

@Zarkys
Zarkys commented Jan 10, 2016

Excelente, realmente ΓΊtil, me funciono el paquete de actualizaciΓ³n.

@telsub
telsub commented Jan 14, 2016

Thank You!!!!

@AlexKurinnoy

Thank you! It works.

@HansiCollaku

But in that directory i already have a file with the same name as the one i downloaded.

@Helen360

Thank you so much!!!

@newgeneration-kdh

how to solve in ruby ver 4.2.4?

@AaronStack

Mehn you rock!!!!!!!!!!!!

@hafizaina

Thanks you!!! Easy, straight-forward, and to the point!

@smosab
smosab commented Feb 10, 2016

Perfect. Thank you!

@Coroecram

Thanks for the post! I did some editing of the article to improve grammar and readability.

https://gist.github.com/Coroecram/74ae51b491445ec454ac

@RAZA-ABBBASI

bundle of thanks! love you dear πŸ‘

@pjs2005
pjs2005 commented Feb 16, 2016

Thank you

@dlakatos847

@bk2git
In my situation, the problem was caused by file permission problems. The user didn't have read permissions on the new .pem files. (I'm on openSuSE 42.1 though)

πŸ‘ for this tutorial

@AaronStack

you are a blessing..............

@DaveRGP
DaveRGP commented Mar 7, 2016

Fantastic, totally works. Needed this to try and sort out a jekyll installation.

Potentially worth noting: If the rubygems-update-2.0.15 is installed, it will work fine for ruby version 2.0.14.

@simba4everyoung

Life saving! Thx!

@DT-Bayou

Never got the fix above to work but was successful with the following:

Setup:
Windows 7 64bit
Ruby installer Ruby 2.2.4 (x64)
Ruby Dev Kit DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe

After installing, Download the cacert.pem file from http://curl.haxx.se/ca/cacert.pem. Save this file to output of the command: gem which rubygems + ssl_cert. For me this was: C:\Ruby22-x64\lib\ruby\2.2.0\rubygems\ssl_certs.

Last create a environment variable called "SSL_CERT_FILE" with a value to the cert file you downloaded, mine would be: "C:\Ruby22-x64\lib\ruby\2.2.0\rubygems\ssl_certs\cacert.pem"

I had to close and reopen my Eclipse with Aptana plugin to pickup the new environment variable.

Credit to the following post that is similar: https://gist.github.com/fnichol/867550

@zhoulujun

草ζ³₯ι©¬ηš„rubyοΌŒζŠ˜θ…Ύζ­»δΊΊηš„SSL_connect certificate verify failed]
http://www.zhoulujun.cn/zhoulujun/html/tools/grunt/2016_0331_7730.html
^^^__you can see detail

i recommend u install local β€”β€”β€”β€”β€”β€”β€”β€”
gem install --local ___your file path(of gem file)

@JeNeSuisPasDave

With Ruby 2.2.3p173 and gem 2.4.5 on Windows 8.1 (x64), just manually adding the updated certificate DID work for me.

But on Windows 10 using the same Ruby 2.2.3p173 and gem 2.4.5, manually adding the updated cert did NOT work. I had to update 'rubygems' to version 2.4.8 using the rubygems-update mechanism outlined above.

I found the correct rubygems-update gem file here: https://rubygems.org/gems/rubygems-update/versions

I've also written up an explanation of these issues with a simple guide for resolving the RubyGems SLL and certificate issues.

@steady-daddy

The certificate download link is broken. [https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem]

No certificate file found.

@jjgh
jjgh commented May 2, 2016 edited

Win 7 64bit.

What I don't understand is, why am I getting again this error after uninstalling Ruby 2.2, freshly installing Ruby 2.3, and updating Rubygems to v. 2.6.4 (with gem update --system)? Also, the Rubygems version shipped with Ruby 2.3 should be immune from this error already, shouldn't it?
Since the .pem file is already present in both C:\Ruby23-x64\lib\ruby\site_ruby\2.3.0\rubygems\ssl_certs\rubygems.org and C:\Ruby23-x64\lib\ruby\2.3.0\rubygems\ssl_certs, then why is it not working and still showing the SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed error message?

@nkuligoski
nkuligoski commented May 17, 2016 edited

@jjgh I am also on Windows 7. Although, I am running ruby 2.2.4p230, I am still receiving the same errors as you. Have you been able to find a fix?

Edit: A fresh install of ruby does not change anything. Still currently unable to download the cert from the link above. (not found)

@pliniociccio

Thank you πŸ‘

@jeffmichaud

If you're like me and none of the above approaches resolved the issue, try this option which I found on stackoverlow.

Replace the ssl gem source with non-ssl as a temp solution:
gem sources -r https://rubygems.org/
gem sources -a http://rubygems.org/

@shweta-sah
shweta-sah commented Jun 16, 2016 edited

If this pem doesn't work, try https://gist.github.com/fnichol/867550 and follow the manual way to get the cacert.pem file

@RAZAW
RAZAW commented Jun 27, 2016

Many thanks!

@sudogem
sudogem commented Jun 27, 2016

The download link above (https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem) is broken :(

So to those who are looking for the certificate file I put it in gist [https://gist.github.com/sudogem/6cc2d710ed1e43b102fc136e9396dea8]
I copied the cert file in my directory which is C:\Ruby215\lib\ruby\2.1.0\rubygems\ssl_certs
Now I can do $ gem install bundler and it works great!!

My setup:

C:\>ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]
C:\>gem --version
2.2.2 
C:\>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby215/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: C:/Ruby215/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby215/bin
  - SPEC CACHE DIRECTORY: C:/Users/armano/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby215/lib/ruby/gems/2.1.0
     - C:/Users/armano/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
@lluis
lluis commented Jul 7, 2016

thanks @sudogem!

@melvinodsa

@luislavena. Thanks for the workaround. It seems to work with RubyGems 1.8. But for some reasons, I need to use 2.2. It doesn't work. When I update to 1.8, I see the changelog in console as

== 1.8.30 / 2014-12-21

Bug fixes:

  • Backport: Add alternate Root CA for upcoming certificate change.
    Fixes #1050 by Protosac

but it is missing in 2.2. etc. I have really been stuck at this.

@toadle
toadle commented Aug 23, 2016

I think this is fixable much more easy. See this https://toadle.me/2016/08/23/fixing-failing-ssl-verification-windows.html

@ChicasFootball
ChicasFootball commented Oct 5, 2016 edited

Still struggling when I try and obtain a new trust certificate I get "404: Not Found".

gem version is 2.5.1
ruby version - ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

I thought to this point I had followed the instructions pretty well but it's not looking good now :(. Any thoughts?


Found another source and problem seems to be resolved now

@itiswicked

@ChicasFootball can you point us to this resource?

@panatl
panatl commented Oct 5, 2016

@ChicasFootball did you resolved this on >= 2.2.2? Can you please care to share?i am having this on Ubuntu 14

@timo002
timo002 commented Oct 5, 2016 edited

Running on OSX 10.11.6 (El Capitan). Same issue here.
Using vagrant for local development and since today my vagrant provision command is failing on:
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)

Solutions mentioned in this thread don't seem to work.
gem version: 2.4.5
ruby version: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

@andrewcrabb

@toadle's answer (23 August) worked for me. Follow the link to his comprehensive blog post. Short story: set environment variable SSL_CERT_DIR to /mingw64/ssl/certs, and SSL_CERT_FILE to /mingw64/ssl/cert.pem.
Easy in bash but I'm using PowerShell (just to make it harder) so envt vars get set in System -> Advanced system settings -> Environment variables. And the PowerShell command to list environment variables is Get-ChildItem Env:.

@prewk
prewk commented Oct 6, 2016 edited

@timo002 You're not alone, please write here if you find a solution.

Update: Our PuPHPet based vagrant boxed solved the problem in this commit: https://raw.githubusercontent.com/puphpet/puphpet/a905085f8f4ac3fc00d51d2a348fc8b02e52f67d/archive/puphpet/shell/install-puppet.sh

@pavkhural
pavkhural commented Oct 6, 2016 edited

@prewk The following worked for me for CI build agents running on WIndows Server 2012 R2, the 2 Environment variables can be added via PowerShell

[System.Environment]::SetEnvironmentVariable("SSL_CERT_DIR", "C:\Program Files\Git\mingw64\ssl\certs", "Machine")

and

[System.Environment]::SetEnvironmentVariable("SSL_CERT_FILE", "C:\Program Files\Git\mingw64\ssl\cert.pem", "Machine")

replace mingw64 wth mingw32 if using the 32 bit version of Git

@elrob
elrob commented Oct 6, 2016

I've managed to fix this on our build machine. I've automated the installation of git bash and the updating of the SSL environment variables.

Run this as a powershell script:

& wget -OutFile git-for-windows.exe https://github.com/git-for-windows/git/releases/download/v2.10.1.windows.1/Git-2.10.1-64-bit.exe
Start-Process ./git-for-windows.exe -Wait -ArgumentList "/silent"
[Environment]::SetEnvironmentVariable("SSL_CERT_DIR", "C:/opt/git/mingw64/ssl/certs", "Machine")
[Environment]::SetEnvironmentVariable("SSL_CERT_FILE", "C:/opt/git/mingw64/ssl/cert.pem", "Machine")
$env:SSL_CERT_DIR = [System.Environment]::GetEnvironmentVariable("SSL_CERT_DIR","Machine")
$env:SSL_CERT_FILE = [System.Environment]::GetEnvironmentVariable("SSL_CERT_FILE","Machine")
@fmondaini
fmondaini commented Oct 6, 2016 edited

The link to the trust certificate is down 😒

@alismayilov

Link for trust certificate does not work.

@pavkhural

Also your will need to reboot your machine / server after adding the environment variables for the rubygems install / update to work

@gksmithlcw

I just installed the most recent release of Ruby for Windows which, apparently, comes with gem 2.5.1 and I'm getting this same error trying to install svn2git. Is this a problem with the gem application itself or a problem with a server. What's the fix? I apologize but I'm having a tough time getting through the weeds here and, per the tutorial, it looks like this issue should've been cleared up a long time ago.

Thanks in advance!

@binki
binki commented Oct 6, 2016

Why doesn’t modern ruby for windows distro come with GlobalSignRootCA.pem? Garr, this is such a pain to manually do on every install. Because the link is broken, I just used SeaMonkey’s export tool to export the GlobalSign Root CA (serial number 04:00:00:00:00:01:15:4B:5A:C3:94) to a PEM file (you should be able to do this somewhere in the Options menu of anything Mozilla-based) and copied that to the ssl_certs directory. I guess at least you don’t have to do anything like run a magical β€œregister this cert” command, so it was actually quite straightforward. And this guide is still useful even if the cert it points to is wrong.

@jbucaran
jbucaran commented Oct 7, 2016

Link to the trust certificate seems to be down.

404: Not Found
@raoel
raoel commented Oct 7, 2016 edited

windows 10, 64 bit, anniversary update

I tried both solutions with 2.0, 2.2, 2.4, no luck...

To get the certificate I used the one-liner miau provided, the certificate shows up in explorer in the correct folder, so that seems to be OK.

Still I'm getting this:

ERROR: Could not find a valid gem 'compass' (>= 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)

C:\Users\raoel>gem --version
2.2.5

C:\Users\raoel>where ruby
d:\Ruby21\bin\ruby.exe

C:\Users\raoel>gem install --local d:\rubygems-update-2.2.3.gem
Successfully installed rubygems-update-2.2.3
Parsing documentation for rubygems-update-2.2.3
Installing ri documentation for rubygems-update-2.2.3
Done installing documentation for rubygems-update after 0 seconds
1 gem installed

C:\Users\raoel>update_rubygems --no-ri --no-rdoc
RubyGems 2.2.3 installed



------------------------------------------------------------------------------

RubyGems installed the following executables:
        d:/Ruby21/bin/gem


C:\Users\raoel>gem --version
2.2.3

C:\Users\raoel>gem uninstall rubygems-update -x
Removing update_rubygems
Successfully uninstalled rubygems-update-2.2.3

C:\Users\raoel>gem --version
2.2.3

C:\Users\raoel>gem install compass
ERROR:  Could not find a valid gem 'compass' (>= 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)


@YetiCGN
YetiCGN commented Oct 7, 2016

Yes, can't download either!

@raoel
raoel commented Oct 7, 2016

@binki now you are my hero :-)

Download here:
https://support.globalsign.com/customer/portal/articles/1426602-globalsign-root-certificates

Convert to PEM on some random website ()

Copy to:
\lib\ruby\2.3.0\rubygems\ssl_certs

@alexharv074
alexharv074 commented Oct 7, 2016 edited

I did this:

To workaround the link being down:

$ curl https://github.com/rubinius/rubinius/blob/master/library/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem -o AddTrustExternalCARoot-2048.pem
$ mv AddTrustExternalCARoot-2048.pem /c/Ruby23-x64/lib/ruby/2.3.0/rubygems/ssl_certs/

Now getting:

$ gem install bundler --no-ri --no-rdoc
ERROR:  While executing gem ... (OpenSSL::X509::StoreError)

It was mentioned by another user above.

Is the cause of this issue known?

@Cl3MM
Cl3MM commented Oct 7, 2016

Thanks @raoel and @binki πŸ‘ !

Here is what I did:

  • download R1 GlobalSign Root Certificate from GlobalSign
  • convert to PEM file: openssl x509 -in Root-R1.crt -inform der -out mycert.pem -GlobalSignRootCA.pem PEM
  • place GlobalSignRootCA.pem in rubygems\ssl_certs
  • profit 🀘
@photonstorm

Phew.. finally got this working. What a royal pain in the ass! Here is how I did it (based on @Cl3MM post above):

  1. Download R1 GlobalSign Root Certificate: https://secure.globalsign.net/cacert/Root-R1.crt
  2. Save it somewhere local, so you can easily access it from a command prompt. It should save with the name Root-R1.crt.
  3. Convert to a PEM file. Here is where the post above didn't work for me, but this did: openssl x509 -in Root-R1.crt -out mycert.pem -outform PEM -inform DEF
  4. Copy the new mycert.pem file that it creates into: D:\Ruby23-x64\lib\ruby\2.3.0\rubygems\ssl_certs <-- this path will obviously be different depending on where you've got Ruby installed!

I can now install gems properly without any more annoying SSL errors. This was on Windows 10 Anniversary edition with Ruby 2.3.1

@MJBrennan

@photonstorm This worked for me thanks!

@alexharv074

What worked for me was simply downloading the latest RubyGems as a TGZ from here and follow the install instructions from there. No more SSL issues.

@hellrider200

Had the same issue today and did what @alexharv074 did.. only I downloaded from Releases the latest 2.6.7 zip and installed manually...
No more issues...

@baweaver
baweaver commented Oct 7, 2016

None of the above solutions are currently working.

Tried:

  • Upgrading RubyGems to 2.6.7
  • SSL cert mentioned in guide (404 broken)
  • Downloading and installing GlobalSign cert

So is this a thing for every upgrade of RubyGems?

@rwingard
rwingard commented Oct 7, 2016

@photonstorm Worked for me as well--also on Windows 10 Anniversary and ruby 2.3.1. Thank you very much!

@kapoorlakshya
kapoorlakshya commented Oct 7, 2016 edited

In addition to the steps by @Cl3MM and @photonstorm, I also had to add an environment variable in Windows to make it work:

Name: SSL_CERT_FILE
Value: C:\Opt\Ruby\Ruby193\mycert.pem

I found this in https://gist.github.com/fnichol/867550

@baweaver
baweaver commented Oct 7, 2016

Mac OSX Fix

For some stupid reason the openssl libs are borked too, so I hard-resetted them all.

brew uninstall --force openssl
brew install openssl

It's either that or a combination of the above steps as well with getting the latest RubyGems ala https://gist.github.com/luislavena/f064211759ee0f806c88#gistcomment-1892332

@fmondaini

Thankyou @kapoorlakshya, @Cl3MM and @photonstorm. Now I've got it working.

@fifiteen82726

@baweaver’s solution works for me.

@dgilperez

It looks like Rubygems updated their certificate.

For RVM users:

rvm get stable
rvm osx-ssl-certs update all
rvm rubygems latest
@PDaily
PDaily commented Oct 8, 2016

Solution posted by @photonstorm worked perfectly for me on Win 10 :)

@robgha01
robgha01 commented Oct 8, 2016

I tested the solution posted by @photonstorm but it dide not work for me i installed the ruby "Ruby 2.3.1-p112" but i get

ERROR:  Could not find a valid gem 'sass' (>= 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/specs.4.8.gz)

i can however reach that file using the browser and url "https://api.rubygems.org/specs.4.8.gz"...

@Ingosmar89219

the solution is with @alexharv074. I did his options he said and RUN :DD!! i have windows 8.1 and now run correctly

@DHB
DHB commented Oct 8, 2016

Solution posted by @photonstorm worked like a charm. Windows Anniversary edition, MRI 2.3.1p112 [x64-mingw32] ...
Had suddenly problems to gem install arel 7.1.3. @photonstorm: Thank you so much.

@jcalestani

If you have the same configuration like me : Windows and Rubygems 2.4 I would recommend to upgrade to Rubygems 2.6 ( the phrase "Specially since RubyGems 2.4 is broken on Windows." found in the tuto made me ). to do so :

1/download the latest version : https://github.com/rubygems/rubygems/releases/tag/v2.6.7

2/and install it with :

C:>gem install --local C:\rubygems-update-2.6.7.gem

change the above path if needed

C:>update_rubygems --no-ri --no-rdoc

@jJayyyyyyy

@jeffmichaud not safe but works(use http instead of https)

@ceefour
ceefour commented Oct 9, 2016 edited

@Jcalestani no .gem, just .zip and .tar.gz :(

Update: I got it from https://rubygems.org/pages/download

Wow, your step-by-step worked! Thanks!

@realvjy
realvjy commented Oct 9, 2016

404 Not found AddTrustExternalCARoot-2048.pem

@realvjy
realvjy commented Oct 9, 2016

@photonstorm thanks, Your tips work

@RohanImmanuel

@jcalestani & @ceefour it worked Thanks

@marlofs
marlofs commented Oct 9, 2016

i tried to install sass and encountered an error ssl something. i got mine worked using the following:

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

then

gem install sasss

Source

@borela
borela commented Oct 10, 2016

@photonstorm Thank you.

@altbdoor
altbdoor commented Oct 10, 2016 edited

This whole Gist is actually properly documented on rubygems/guides, but it appears that the page is a little outdated as well.

For anyone interested, the SSL cert link is not exactly broken. Its just that RubyGems restructured their folder. The same SSL cert can be found in the link below.

https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem

@graychurch

Thank you, thank you, thank you for posting this. I would never have been able to get past this problem without your helpful instructions. (And yes, I read the whole article, and your embedded "thank you for reading" made me smile.)

@wclear
wclear commented Oct 11, 2016

For Windows 10 64-bit, RubyGems v2.5.1: downloading all the SSL certificates from the subfolders in https://github.com/bundler/bundler/tree/master/lib/bundler/ssl_certs and saving them into the C:\Ruby23-x64\lib\ruby\2.3.0\rubygems\ssl_certs (at least that's the path after a fresh installation today) folder seemed to work. There was no need to recreate the subfolder structure, just put all files directly into the ssl_certs folder. Existing files with the same name were overwritten.

@sarog
sarog commented Oct 11, 2016

Guys, there's an even simpler method.

I created a new file called root-r1.pem inside the folder C:\Ruby23-x64\lib\ruby\2.3.0\rubygems\ssl_certs and then copy/pasted the following GlobalSign Root R1 certificate (click "View Base64"). It worked on Windows 10 x64 without having to mess around with OpenSSL DER/PEM conversions.

-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG
A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw
MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT
aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ
jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp
xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp
1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG
snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ
U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8
9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E
BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B
AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz
yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE
38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP
AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad
DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME
HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
-----END CERTIFICATE-----
@Firenz
Firenz commented Oct 11, 2016

@jcalestani thanks!! It worked ^_^

@pawitk
pawitk commented Oct 12, 2016

@sarog thanks for the simplified solution! I got it working in minutes!

@alexbaulch

@sarog you are a hero, that saved so much time

@michielreyers

@sarog, Dude you're a hero! Tried all the other solutions but none worked.
Can you explain why you create a new .pem file with a new name?

@adrianandreias

@sarog saved the day!

Thanks!

@balmyBanzai

Thanks a ton, @sarog! Worked like a charm.

@Marsrocky

@sarog OMG thank you very much though I don`t know why it works. :)

@mrstebo
mrstebo commented Oct 13, 2016

@photonstorm Your solution worked for me.

@justinconnell

@sarog well done! I love your solution it should be bumped up to the top of the page

@Fatekiller23
Fatekiller23 commented Oct 13, 2016 edited

....seems only i get error msg...after follow your steps. updated: hah ,thanks @sarog his solution works.

@SamirSouzaSys

@sarog @justinconnell

i agree, your solution @sarog worked for me.

@SuhairZain

@sarog Worked for me as well. Thanks man. πŸ‘

@smosab
smosab commented Oct 13, 2016

Thank you. This was vey helpful!

@jaminscript

@photonstorm Solved! In my case it took about 1 minute for anything to happen after running gem install jekyll bundler, but it worked!

@Pizdetss
Pizdetss commented Oct 14, 2016 edited

Still doesn't work for me. Even after trying all the above.
Windows 7
ruby 2.1.5p273
gem 2.6.7
copied certificate GlobalSignRootCA.pem from http://guides.rubygems.org/ssl-certificate-update/ to rubygems\ssl_certs folder
ran: gem install bundler
result: 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/specs.4.8.gz)

EDIT: Changing source to http instead of https worked.

@terev
terev commented Oct 14, 2016

@wclear thanks! this worked for me too

@thesorin

@sarog thanks!

@zhouleink

@sarog thanks! your solution worked quite well for me!

@GuitarKat

@sarog Thanks for the fix. :)

@cyuno
cyuno commented Oct 15, 2016

Using upgraded windows 10 from windows 7. The pem file link is broken. I uninstalled older versions of Ruby. Installed the latest stable version of Ruby (Ruby23). No problems at all.

@sunilcemk06

Thanks @Sarog !!

@largobox

@Sarog you are awesome

@jonasjancarik

Seems like the folder structure was changed, so the link to AddTrustExternalCARoot-2048.pem doesn't work anymore. I tried the same procedure with AddTrustExternalCARoot.pem (couldn't find the -2048 version) but that didn't work. (Maybe one of the other .pem files would - like GlobalSignRootCA.pem).

In the end I went with @sarog's solution, which worked. Kudos both @luislavena and @sarog!

@aida-martinez

@wclear thanks! Totally worked for me.

@graballweb

It's alive! Thx @sarog for this

@edwardluzi

set SSL_CERT_FILE=C:\Ruby200-x64\lib\ruby\2.0.0\rubygems\ssl_certs\AddTrustExternalCARoot-2048.pem works for me.

My version gem 2.5.1

@PatrickWalker

I just followed the steps here http://guides.rubygems.org/ssl-certificate-update/
Downloads a new version of the ruby gem locally and allows you to upgrade and that was me. Really quick fix

@drnic
drnic commented Oct 17, 2016

Thanks @patrickwalker - guides instructions worked a treat.

@nimi09
nimi09 commented Oct 17, 2016 edited

this is ridiculous . can't get it to work on osx 10.10.5 Yosemite

I am on
ruby 2.2.4p230
gem 2.6.7
Rails 4.2.5.1
OpenSSL 1.0.2h 3 May 2016

when i start a new rails app I get the following error:

Fetching source index from https://rubygems.org/
Retrying fetcher due to error (2/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.

added the certificate as described at http://guides.rubygems.org/ssl-certificate-update/

@mixelpixel

Thank you for this!!!! Am using win7 on a 2009 hp lappy and had rubygems v2.4 installed - now I have 2.6.7 πŸ˜„

@mfDK
mfDK commented Oct 19, 2016

I did both of these instructions here http://guides.rubygems.org/ssl-certificate-update/ and I'm still getting the SSL error. Anyone else have the same issue?

@pmarco777

New link to certificate, since the one above is broken: https://curl.haxx.se/ca/cacert.pem

@markwintch

I got file not found when trying to download certificate. I believe this is the text of the certificate that we can use to create it.

-----BEGIN CERTIFICATE-----
MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU
MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs
IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290
MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux
FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h
bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v
dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt
H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9
uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX
mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX
a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN
E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0
WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD
VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0
Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU
cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx
IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN
AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH
YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC
Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX
c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a
mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
-----END CERTIFICATE-----

@delmattos

It works here, thank you! πŸ‘

@ArtOfDev

Thank you. I shold look here http://guides.rubygems.org/ssl-certificate-update/ to find the new certificate.

@csaden
csaden commented Oct 21, 2016

I faced the same error (on Mac OSX 10.10.5 Yosemite).

OpenSSL Errors and Rails – Certificate Verify Failed

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

I deleted rvm and and re-installed but still faced the same problem. I could not brew link --force openssl and ended up stumbling upon this for the solution.

rvm install 2.2.4 --disable-binary
Install whatever ruby version you need.

http://stackoverflow.com/a/18344044/4830231

@nimi09
nimi09 commented Oct 21, 2016

@csaden thanks, that worked for me!!!

@adeelhussain

Not work for me :(
Having the gem version of 2.5.1
It works before but not working since last three days!

@Dave-Piland
Dave-Piland commented Oct 22, 2016 edited

Not sure if I'm just not following these correctly but none of the above fixes worked for me. HOWEVER, following the steps here fixed the problem with the SSL certs and I can continue gem installs without issue:
https://superdevresources.com/ssl-error-ruby-gems-windows/

*_I swapped "Rails" with "Ruby"
*_Gem version 2.0.15
**Shout out and HUGE THANKS to Kanishk Kunal for figuring this one out

@ninoM
ninoM commented Oct 22, 2016

Holy shit @Dave-Piland you're my fucking hero. Literally nothing worked till I tried out your solution. I don't think where the cacert.pem file is located matters though. I put mine on C:\RailsInstaller\Ruby2.2.0\lib\ruby\2.2.0\rubygems\ssl_certs and just pointed the system variable there. Thanks so much!!!

@h404bi
h404bi commented Oct 22, 2016

@Dave-Piland πŸ‘ you save my life!

@TheHighPriestess

The solution of @marlofs worked for me. Thank you!

@Anke
Anke commented Oct 22, 2016

Thank you, @sarog, just perfect!

@welkie
welkie commented Oct 23, 2016

Download link for .pem file 404s.

@mikhaildubov

The original solution didn't work for me (Windows 8 x64) the the one by @sarog did. Thank you @sarog!

@beni92
beni92 commented Oct 24, 2016

Thank you @sarog πŸ‘

@karthigamahe

i got error while i give bundle install

bundle install
C:/Ruby23/lib/ruby/2.3.0/rubygems/dependency.rb:319:into_specs': Could not find 'bundler' (>= 0) among 11 total gem(s) (Gem::LoadError)

@andreymakaroff

I fixed this problem:
gem source -a http://rubygems.org/

@cjwpstudio5

I can confirm that the solution suggested by @Dave-Piland and @kanishkkunal work well.

Error with Ruby Gems on Windows

If you're not keen to define a System Variable for the SSL_CERT (e.g. if you're using a portable dev stack on Windows), then you can combine Kahnishk's instructions with points 2 and 3 of @luislavena's "Manual solution to SSL issue", above.

I noticed that the AddTrustExternalCARoot-2048.pem in this gist is now a 404; so use the link to Kahnishk's cacert.pem instead:

cacert.pem

Hope this helps someone.

Props to @Dave-Piland, @kanishkkunal, and of course @luislavena

@agdenadel

This page has a solution to the problem

http://guides.rubygems.org/ssl-certificate-update/

@Trenking

THANK YOU! THAT WORK!

@kimpastrodb1

In Windows 10, I've just downloaded the zip at https://rubygems.org/pages/download and executed it. Done!

  • Ruby 2.2.5p319
@DWishR
DWishR commented Oct 25, 2016 edited
@sirokeez

How to save the .pem file? I have saved it as "cacert.pem", but the document is still a txt file. Please help

@alexblum

@kimpastrodb1 πŸ‘

@sirokeez

had to save it with firefox. Fsome reason chrome always saved in in text file. Thank u for ever!!!

@deadlydog

To solve the problem I:

  1. Downloaded the new cert file from: https://curl.haxx.se/ca/cacert.pem
  2. Dropped the cacert.pem file in C:\Ruby22-x64\lib\ruby\2.2.0\rubygems\ssl_certs
    That's it.
@dthor
dthor commented Oct 26, 2016

what to do without admin control? This doesn't work without access to advanced settings?

@sabrinashie

I've updated my certificates multiple times, but nothing seems to be working. Running on OSX. Any advice?

@nni123
nni123 commented Oct 27, 2016

@deadlydog Thanks so much your solution worked for me (Windows 10-64). I tried many options before this.

@wojcikm
wojcikm commented Oct 28, 2016 edited

@alexharv074 Works, thanks a lot. Spend whole night looking on that! // Win 10, Ruby 2.2.5 x64

@bharath01

@deadlydog Thanks man

@mrose-mpd
mrose-mpd commented Oct 29, 2016 edited

Edit: These instructions from a few comments above solved it for me:

To solve the problem I:

  1. Downloaded the new cert file from: https://curl.haxx.se/ca/cacert.pem
  2. Dropped the cacert.pem file in C:\Ruby22-x64\lib\ruby\2.2.0\rubygems\ssl_certs
    That's it.
@dumptyd
dumptyd commented Oct 30, 2016

@mrose-mpd 's solution worked for me.

@ayushkamadji

The ssl certs link seem to not work for me. I tried https://github.com/rubygems/rubygems/tree/master/lib/rubygems/ssl_certs instead and replaced all certificates under installation dir/ssl_certs with the ones on the repo under said directory / sub-directory. Hope that helps.

@s-nordquist

Thank you!

@cliffmutegi

Thanks this has been a problem for quite sometime. The solution for me was updating gem to version 2.6.8

@jamiehutber

The file is no longer available.

@ghost
ghost commented Oct 31, 2016 edited

yes 404ing at 22:00 GMT

@Beautyod
Beautyod commented Nov 1, 2016

Great article - thanks (-:

As others said: It's nice when you update the certificate link.

@monkodev
monkodev commented Nov 2, 2016

Awesome!!! Thanks!!

@y-takashina

I succeeded updating SSL certificate in this way.
http://guides.rubygems.org/ssl-certificate-update/

@jcabasc
jcabasc commented Nov 3, 2016 edited

@dgilperez thanks man, what you said did the trick for me, so either that and/or copy the .pem file inside the ssl_certs folder of my ruby version.

@rbur004
rbur004 commented Nov 4, 2016

I finally found which cert.pem file I needed to update. I had updated with update_rubygems, first to 2.6.7, and then to 2.6.8. Neither fixed the issue.

certfile=ruby -ropenssl -e "puts OpenSSL::X509::DEFAULT_CERT_FILE"
echo $certfile

That turned out to be /usr/local/ssl/cert.pem , as I had installed the latest openssl there, and built ruby to point to this version of openssl. You might find it is somewhere else.

On my Mac, I then updated it with
security find-certificate -a -p /Library/Keychains/System.keychain > $certfile
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> $certfile

The root certs had been updated by my browser.

On Linux, I scp'd the cert file to that systems $certfile

@cj13579
cj13579 commented Nov 4, 2016

Unfortunately neither of these solution worked for me but this comment provided the fix that worked for me:

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem update --system
gem source -r http://rubygems.org/
gem source -a https://rubygems.org/

Hope this helps someone else.

@bxmas13
bxmas13 commented Nov 4, 2016 edited

@cj13579
Thanks! Your solution worked great for me(Windows 10).

@jgbneatdesign

Thanks!

@navin09
navin09 commented Nov 6, 2016

Nothing worked for me, until I tried @cj13579's solution. Thank you, @cj13579!

@vickylance

@cj13579 One word you are Awesome..!! :)

@cyp-v
cyp-v commented Nov 6, 2016

@cj13579 's solution seems to work no matter which version. Great, thank you so much!

@lbuskiewicz

Well in my case i still have the problem i try solution from @cj13579 but still have the problem

@YossiCohen

Thanks @cj13579 it works but on http

  • I had to change the Gemfile to work with http instead of https.
    does wnyone have a solution that works with https?
@schleumer

Worked more than me on deadline. Thanks!

@sabrinashie
sabrinashie commented Nov 8, 2016 edited

After a long time, I finally managed to get it to work!!!! YAY!
If you're still having problems on an OSX Yosemite environment with rvm installed, here's what I did:

  1. I did what @cj13579 suggested, but it errored on the last step. Thankfully, it gave me a more specific error than before, specifically, my GlobalRootCA cert was expired.
  2. This link showed me how to delete the expired GlobalRootCA cert/retrieve the unexpired cert: Homebrew/legacy-homebrew#32251
  3. Then I realized my path file was incorrect and it was going to /etc/openssl instead of /usr/local/etc/openssl/certs. You can fix this by disabling binaries as explained here: https://toadle.me/2015/04/16/fixing-failing-ssl-verification-with-rvm.html

Hope this helps!

@vincelord

the link to the pem-file has expired.

@MaxSkyfire

This solution didn't work for me. But I installed latest rubygems-update from https://rubygems.org/gems/rubygems-update/versions and run

update_rubygems

and now it works.

@henrythedj
henrythedj commented Nov 8, 2016 edited

This solution hasn't worked for me yet - I tried @MaxSkyfire 's solution and I still got the same error.

Luckily, @cj13579 provided a solid answer up there ^ (from here ) reposted here for posterity:

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem update --system
gem source -r http://rubygems.org/
gem source -a https://rubygems.org/

@Nexxado
Nexxado commented Nov 9, 2016

@MaxSkyfire same worked for me.

Steps taken:

  1. Download rubygems_update version 2.6.8 (latest version at this time)
  2. Install rubygems_update: gem install rubygems-update-2.6.8.gem
  3. Run it update_rubygems --no-ri --no-rdoc
  4. Make sure gem -v returns version 2.6.8
  5. [Optional] Uninstall rubygems_update: gem uninstall rubygems-update -x

now everything works fine.

@Mazorati
Mazorati commented Nov 9, 2016

Still have this error:

iMac:Downloads Admin$ gem -v
2.6.8
iMac:Downloads Admin$ gem install cocoapods
ERROR:  SSL verification error at depth 2: certificate has expired (10)
ERROR:  Certificate /C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA expired at 2014-01-28T12:00:00Z
ERROR:  SSL verification error at depth 2: certificate has expired (10)
ERROR:  Certificate /C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA expired at 2014-01-28T12:00:00Z
ERROR:  SSL verification error at depth 2: certificate has expired (10)
ERROR:  Certificate /C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA expired at 2014-01-28T12:00:00Z
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=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)
ERROR:  SSL verification error at depth 2: certificate has expired (10)
ERROR:  Certificate /C=BE/O=GlobalSign nv-sa/OU=Root CA/CN=GlobalSign Root CA expired at 2014-01-28T12:00:00Z
@jeesus
jeesus commented Nov 11, 2016

@MaxSkyfire thanks, man!

@micdemarco

thanks @Nexxado steps worked

@jdinkla
jdinkla commented Nov 11, 2016

@Nexxado @MaxSkyFire it works on my Window 10 machine. Thanks! I took the same 5 steps as @Nexxado.

@thybzi
thybzi commented Nov 12, 2016 edited

One more simple way with RubyGems 2.5.1 on Windows (worked for me to fix gem install rhc on Windows 10 x64)

Long story: https://toadle.me/2016/08/23/fixing-failing-ssl-verification-windows.html

Short story:

  1. open git bash (Mintty, four-colored icon)
  2. set env vars: export SSL_CERT_DIR=/mingw64/ssl/certs && export SSL_CERT_FILE=/mingw64/ssl/cert.pem
  3. now you can install your favorite gems in this console
@thybzi
thybzi commented Nov 12, 2016 edited

But this solution from @Nexxado must be the best (as it actually updates rubygems version): https://gist.github.com/luislavena/f064211759ee0f806c88#gistcomment-1917478

@johnnybionic

Thanks @y-takashina - I tried a few other solutions from this page, but all resulted in the same problem I was trying to fix :) That page worked for me

@anita-brooks

@thybzi Your short history saved my life good sir, I owe you a beer.

@NickMind

Thank you henrythedj you are lifesaver

@park53kr

@sarog save my life

@leekelleher

(as above) Thanks @Nexxado, the steps worked on my Window 10 machine πŸ‘

@Rorkal
Rorkal commented Nov 16, 2016

The solution #1 here worked or me : https://gist.github.com/eyecatchup/20a494dff3094059d71d

1. Add insecure source

gem sources -a http://rubygems.org/
https://rubygems.org is recommended for security over http://rubygems.org/

Do you want to add this insecure source? [yn] y
http://rubygems.org/ added to sources

2. Remove secure source

gem sources -r https://rubygems.org/
https://rubygems.org/ removed from sources

3. Update source cache

gem sources -u
source cache successfully updated

@Gratefull

I want to thank so many people, it was a ride. (ruby 2.3.0 ; rubygems 2.5.1)

Here's what got me through:
Section Title: " Solution #3 and #4. "
https://gist.github.com/eyecatchup/20a494dff3094059d71d#solution-1-change-default-source-host-from-https-to-http

It tells you to:

  • 'Save as...' the page on the following link and name it "ca-bundle.crt": https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt
  • Put the "ca-bundle.crt in the ssl_certs map: "C:\row\Ruby23\lib\ruby\2.3.0\rubygems\ssl_certs"
  • Open cmd type: "openssl" press enter, and paste "x509 -in ca-bundle.crt -out MozBundleCA.pem -outform PEM" press enter
  • Install your gem again.

I was struggeling with getting openssl. So here's what helped me out with that:
Title: " How to install Openssl on Windows7 "
https://www.youtube.com/watch?v=JLPzEbNDHwQ

@Carleslc

Thank you @Gratefull, worked for me on Win10.

@anilkonsal

@Gratefull, your solution worked for me. Thanks!

@joehany
joehany commented Nov 21, 2016

Thanks @sarog worked!

@mhafellner

Thanks @Nexxado your solution worked flawlessly on Win 10 x64 with Ruby 2.3 and gem 2.5.1 installed!

@PauloFrancaLacerda

Thank you, @Gratefull. Worked for me at a glance (for Firefox 50.0 on Windows 7 32-bit).

@jullus
jullus commented Nov 25, 2016

Thanks @Gratefull your solution worked flawlessly on Win 10 x64 with Ruby 2.3 !!!

@ghost8472

Thanks @Gratefull for that final bridge.

@Nitropox

thanks @Nexxado. Win 10 x-64 Ruby 2.3.1

@AumCoin
AumCoin commented Nov 28, 2016

Ruby is so f*cking stupid, I wish I had just learned Python years ago instead of this crap. My 1.93 install broke and there was no obvious way to fix it, so I figure I'll try one of these RubyInstallers. Of course I get this stupid SSL message. Every time I try to do anything new with Ruby it requires half a day of looking for "workarounds". I find my way to this stupid page and the solution doesn't work, because the .pem file link is broken. I'm so sick of this retarded language. The attraction is... slightly faster than Python? This language was never needed. What a stupid, stupid, thing.

@crowchirp

Thanks for the detailed steps.
The Link in 'We need to download AddTrustExternalCARoot-2048.pem.' in Step 1 throwing 404.

@tazzydemon

If you are tearing your hair out with Windows 10 then this works, just ignore the fact that its rails

https://superdevresources.com/ssl-error-ruby-gems-windows/

@ysrb
ysrb commented Nov 30, 2016

You can use this PEM instead - https://curl.haxx.se/ca/cacert.pem @crowchirp

@djibtgy
djibtgy commented Nov 30, 2016

@crowchirp This is a link for downloading AddTrustExternalCARoot-2048.pem : https://github.com/rubinius/rubinius/blob/master/library/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem

I respected all the steps but I still got the same problem :
ERROR: Could not find a valid gem 'fpm' (>= 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/latest_specs.4.8.gz)

@gluons
gluons commented Dec 1, 2016 edited
@cdtinney
cdtinney commented Dec 2, 2016

@gratefull Thank you. Solution worked for me as well. Win10x64, Ruby v2.3.

@itaditya
itaditya commented Dec 2, 2016 edited

Now the link to download the .pem certificate shows 404 Not Found

@jbucaran
jbucaran commented Dec 3, 2016

Thanks for this solution. This is exactly what I did that worked for me on macOS.

gem install rubygems-update --source "http://rubygems.org"
update_rubygems
gem uninstall rubygems-update -x
@nthmai1805

thank you for the guide! Solution worked for me as well

@kakoma
kakoma commented Dec 30, 2016

Even with the official guide up-to-date, this was a great resource. Thanks a lot

@koryteg
koryteg commented Jan 9, 2017

thanks for this! you also might want to link to or, update your docs to include this solution: rubygems/rubygems#665 (comment)

I had the same issue and updating rubygems didn't fix it. but updating openssl-osx-ca did.

just a thought.

@thedamon
thedamon commented Jan 23, 2017 edited
Downloads gem install --local rubygems-update-2.6.7.gem
Successfully installed rubygems-update-2.6.7
Parsing documentation for rubygems-update-2.6.7
Installing ri documentation for rubygems-update-2.6.7
Done installing documentation for rubygems-update after 22 seconds
1 gem installed
➜  Downloads update_rubygems --no-ri --no-rdoc
zsh: command not found: update_rubygems

Not sure if i'm missing something obvious... but this not the work for me! command not found?

@neerajsoni87

The solution is very Simple :)
To connect without using SSL, edit your Gemfile sources and change 'https' to
'http'.

@Rihab
Rihab commented Jan 25, 2017

Works !! Thank you for the workaround. I did not read everything but directly went to the workaround : Installing using update packages

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