Gus
Gus

Reputation: 623

Getting SSL error in ruby on Windows

I get the following error:

C:\Users\user\Desktop\folder>ruby exchange_rate.rb
C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect
returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify fai
led (OpenSSL::SSL::SSLError)
        from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:933:in `connect'
        from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
        from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:852:in `start'
        from exchange_rate.rb:55:in `<main>'

According to

https://gist.github.com/luislavena/f064211759ee0f806c88

and other places with the exact same info this affects only rubygems versions up to 2.2.x

However my installation is: ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32] with rubygems 2.5.1 and I still get it

I tried the manual solution there, after looking for the .pem file somewhere else https://github.com/rubygems/rubygems/blob/master/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem

since the link doesn't work anymore, this is the content of that

-----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-----

which is exactly the same thing I have

I upgraded rubygems to 2.6.4 still getting the same problem

Can anyone can help me get this working?

Upvotes: 3

Views: 9853

Answers (4)

jechterhoff
jechterhoff

Reputation: 175

For me, upgrading to ruby v2.4.3 via the RubyInstaller-2.4.3-1 (for windows) helped. The installer can be downloaded from https://rubyinstaller.org.

Upvotes: 0

Henrik Heimbuerger
Henrik Heimbuerger

Reputation: 10193

What worked for me is downloading a certificate file and pointing the SSL_CERT_FILE environment variable to it. My source is this gist by fnichol. (I was following the "The Manual Way (Boring)" instructions.)

  1. Download http://curl.haxx.se/ca/cacert.pem to some permanent location.
  2. Set environment variable SSL_CERT_FILE to the path of the downloaded file.

Now suddenly HTTPS requests (not related to gem installation) would work for me on Windows 10 using Ruby 2.2.x (x64).

Upvotes: 3

Ed Minshull
Ed Minshull

Reputation: 21

Any one that has installed 2.3.1 this link solved my SSL problems with installing gems in windows.

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

Summary:

  1. Download .pem file from here http://curl.haxx.se/ca/cacert.pem and save to C:\Rails\Installer\cacert.pem.

  2. Right click computer and select properties.

  3. Then click Advanced system settings and then Environment Variables.

  4. Create a new system variable with SSL_CERT_FILE as name and C:\Rails\Installer\cacert.pem as path.

  5. Open a command prompt and verify that you can install a gem.

I.E - gem install watir

Upvotes: 2

Gus
Gus

Reputation: 623

Solved my problem by installing this gem

net_http_ssl_fix

Documentation here:

http://blog.liveeditorcms.com/net-http-ssl-fix-gem/

I don't know why it fixes, why the need of another gem on top of the regular one, but, what the hell, it works!

Upvotes: 2

Related Questions