SSL_Connect Certificate Error with Ruby Fix

While setting up a static environment, I came across this error from running: gem install github-pages (a gem for syncing Jekyll with GitHub Pages):

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)

The problem came from outdated SSL certificates, as explained by Fletcher Nichol in this gist.

A solution was to temporarily replace the https source with http.

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

And then restore the SSL.

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

This was a quick fix, however, using http over https raised security concerns since http didn't include the SSL encryption when installing gems.

The solution:

  • Download the certificate authority cacert.pem file
  • Save it to the RailsInstaller folder located in the (C:)
  • Set an environment variable identifying the file path.

To set an environment variable:

Go to the Control Panel, System and Security, System, and Advanced System Settings. Click on Environment Variables...

New...

Variable name: SSL_CERT_FILE

Variable value: SSL_CERT_FILE=C:\RailsInstaller\cacert.pem

Click OK, close the control panel and re-lanch the command line.

Following this, I was able to install github-pages with success, CD to my project folder and successfully run jekyll server --watch without error.