Ruby gems certificate checking solving giving out some troubles
[The solution present on this post assumes using a unix system]
Are you having the following error when trying to install a gem, or a vagrant-plugin ?
Errno::ECONNRESET: Connection reset by peer - SSL_connect(https://api.rubygems.org/specs.4.8.gz)
So, recently I had to downgrade vagrant, and that meant remove previous Vagrant version and made a purge on all plugins.
When I went on to reinstall a few vagrant plugins, rubygems starts complaining about the certificate and for me to make sure I wasn’t behind a proxy.
In fact, I’m not, but for some reason this problem was also transversal to browser navigation that would give me connection_reset_by_peer on chrome and firefox intermittentely.
Decided to give curl a try as well.
And would return the same sort of error
curl: (35) gnutls_handshake() failed: Error in the pull function.
So how to install gems from rubygems? Well, if it is a transient error, and you wouldn’t mind downloading without SSL/TLS encryption, this is a temporary solution, yet not advisable on the long run for you.
First remove the source on the gems
First list them
Should output something like this
*** CURRENT SOURCES *** https://rubygems.org/
Yes lets go remove that source now, as I’m not behind a proxy nor I can install gems.
gem sources --remove https://rubygems.org
And add a new source
gem sources -a http://rubygems.org
If your issue was to install gems using ruby, this should help.
Don’t forget to revert to SSL/TLS after the problem is actually solved.
If your problem exists when doing a plugin install, i.e. vagrant-lxc
vagrant plugin install vagrant-lxc
Vagrant failed to load a configured plugin source. This can be caused by a variety of issues including: transient connectivity issues, proxy filtering rejecting access to a configured plugin source, or a configured plugin source not responding correctly. Please review the error message below to help resolve the issue: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://api.rubygems.org/specs.4.8.gz) Source: https://rubygems.org/
You can always ignore Vagrant sources for plugins
First define the version of the plugin to install for lxc example below:
wget http://rubygems.org/downloads/vagrant-lxc-1.4.0.gem #It always follows vagrant-$PLUGIN-$MAJOR.$MINOR.$CHANGES.gem
And then just make use of:
vagrant plugin install --plugin-clean-sources vagrant-lxc-1.4.0.gem
This will directly install the plugin.
Will update post if I find out more about the root causes of this issue, for now this helped me install the vagrant plugins I required.