musings between the lines

there's more to life than code

ruby ssl

| Comments


In my tech explorations, I had stumbled across this AngularJS Modules collection project which I thought was a neat project. Written in Ruby, it’s basically a simple way for people to add their AngularJS modules and to list and search for useful modules. I am by far not at all versed in Ruby, which made this something I was not familiar with. But thought it would be an interesting exercise get this running locally and to take a peek under the hood of a simple Ruby project that presented the whole stack.

The site came with a pointer to its GitHub repo, complete with a outlining the steps needed to get it running locally. Well documented and clear instructions, what’s not to love about that.


Scanning the list of requirements, there were things I didn’t yet have installed on Ubuntu 12.10, so off I went. I had to install postgresql (sudo apt-get install postgresql) and pygments (sudo apt-get install python-pygments) but since I already had ruby installed (due to octopress), the rest of the instructions worked out well.

With everything installed and built, all that was left was to hit the big old button (or rather command line: bundle exec rails server) and see it in action. For once, it amazingly worked right out of the box. I now had a nice clone running on localhost:3000. All happiness and fun times… until I hit the “Login with GitHub” button.

It almost worked.


But as we all know, almost isn’t quite good enough. I was greeted with an SSL error:

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

A security issue, oh fun.


I had to do a bit of digging to find out that it was some sort of Ruby configuration issue with SSL and localhost and forced certificate checking. After a bit of searching and probing for answers, I was led to this answer on StackOverflow:

Though another answer that had worked in the interim was to use prepend the Ruby command with the SSL_CERT_FILE environment variable and have that point to the downloaded cacert.pem file, wherever you put it. Something like this:

SSL_CERT_FILE=/etc/ssl/certs/cacert.pem bundle exec rails server

Useful if you can’t reinstall and rebuild Ruby for some reason. With that in place, the callback from GitHub worked fine and I was able to log in with my credentials. The last hurdle was crossed and I finally had a working clone of the project locally. Now I’ll can take a little bit of time and explore the code and see how it was built.


I’m still deciding if Ruby is something I want to jump into and learn or something to bypass in favor of writing backends in Javascript for Node.js or to simply see if Java has made any packaged advances in this area (without the daunting complexity of WS-* services and the usual overblown nature of Java).

But for those that are in Ruby land, I figured others may have had the same issue so I’d post it here in case. Ah, the internet, such a nice place to hang out.

I couldn’t decide if this post should be part of the Ubuntu 12.10 quirks post or something to stand on its own. It ended up being pretty long, so I gave it its own post.