How to tell gem command not to use SSL

Viewed 36360

I am trying to run the gem command to install/update some gems, but due to some network restrictions in this area, I get this error:

ERROR:  While executing gem ... (OpenSSL::SSL::SSLError)
    SSL_connect returned=6 errno=0 state=SSLv3 read finished A

(I think) this is mainly because of tampering with the SSL certificates.
Is there anyway to tell gem not to use SSL, to avoid the error?

2 Answers

Use HTTP instead of HTTPS if you are unable to solve the certs issue:

$ gem install rails --source http://rubygems.org

To avoid repeating this every time, either edit your ~/.gemrc or edit the file through the command line, like this:

$ gem sources --add http://rubygems.org
$ gem sources --remove https://rubygems.org
$ gem sources --list

*** CURRENT SOURCES ***
http://rubygems.org

Also, en every Gemfile you will need to change the first line from:

source 'https://rubygems.org'

To:

source 'http://rubygems.org'

Of course it would be much better if you manage to solve the certs issue as @p11y suggested on his comment.

The accepted answer didn't work for me. The following, however, did.

Edit .gemrc file

  • On Windows c:\Users\yourusername\.gemrc

Specifically %HOMEPATH% in the event your path is different.

add:

:ssl_verify_mode: 0

It displayed the SSL errors but the install was successful.

Related