gem install: Unable to download data

I've had some problems recently with trying to install gems with a brew installed version of ruby 2.0.0. I'm not sure that this limited to Brew installs of Ruby though. I keep getting an error message stating Unable to download data from https://rubygems.org. After a little research, it turns out that the certificates are outdated, and thus preventing me from using the default https protocol to get my gems.

$ gem install [desiredgemname]

ERROR: Could not find a valid gem '[desiredgemname]' (= 0.0.0.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://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz)

All in all this is a pretty easy thing to workaround if you know about gem commands and parameters. There are a couple of ways to get around this temporarily. The less secure way is to change the sources that your gems are pulling from. THIS SHOULD ONLY BE USED TEMPORARILY!

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

On a per 'gem install' basis you can also do the following:

gem install [desiredgemname] --source http://rubygems.org  

But neither of these are a permanent solutions and you will have to remember to add the parms or add/remove sources every time.

After looking around a bit I found a better way to accomplish the same goal on a more permanent basis. I read an article that showed how to update SSL Certs via Brew. The important parts are here:

$ brew update
$ brew install openssl
$ brew link openssl --force
$ brew install curl-ca-bundle

And then in your config you will need to export your newly installed SSL Certs so they can be used.

export SSL_CERT_FILE=/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt  

Hope this helps to consolidate everything. If you see something wrong leave me a comment.

Ray Pierce

Web Developer, RetailMeNot, Mentor, NodeBot builder, Texan

Austin, TX Ya'll http://digitalpierce.com
comments powered by Disqus