Fork me on GitHub

Drew's World

Rants, News, Etc on my Life and Projects

RVM Installed Ruby (SSL certificate verify failed)

by Andrew De Ponte (@cyphactor)

Recently a few of our developers were having problems getting SSL certificate verify failures in Ruby. The error was the following:

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/http.rb:799:in `connect'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/http.rb:799:in `block in connect'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/http.rb:799:in `connect'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/http.rb:744:in `start'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:306:in `open_http'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:775:in `buffer_open'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:203:in `block in open_loop'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:201:in `catch'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:201:in `open_loop'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:146:in `open_uri'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:677:in `open'
  from /Users/adeponte/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/open-uri.rb:33:in `open'

The error was reproducable by running the following Ruby snippet in an irb instance of the RVM installed Ruby version.

require 'open-uri'
open 'https://google.com'

I spent a good amount of time digging into things and trying to figure out exactly what the issue was. I came to the conclusion that they either had an out of date Root CA Certificate Bundle or SSL couldn’t find it for some reason. So, I went down the path of trying to import cacert.pem from http://curl.haxx.se/ca/cacert.pem (cURL’s website).

I went down this path because I vaguely remember doing this at some point in the past to solve the Twitter API SSL Verify fail issue when they changed their certs. I ran into a huge amount of difficulty trying to get the thing imported or converted into a format that Mac OS X Keychain Access would be happy with importing. I tried pem, crt, pck12, etc. Nothing I did seemed to make a difference.

This is when I saw a post of someone talking about SSL being installed inside of RVM and I looked at the latest output from rvm requirements. I quickly noticed that it now says to install SSL via the following command:

rvm pkg install openssl

Come to find out if you have run the above command before installing your Ruby version it will be using the RVM packaged openssl instead of the system openssl. That also means that the Root CA Certificate Bundle is different, or in this case, missing completely.

After discovering this and doing a little googling I found the solution to be as simple as the following command:

curl http://curl.haxx.se/ca/cacert.pem -o ~/.rvm/usr/ssl/cert.pem

I found this solution on the following blog post http://fredwu.me/post/28834446907/fix-openssl-error-on-mountain-lion-and-rvm. Hopefully, writing another blog post on the subject and linking to this one will help it gain its ranks in google search so that other people can find it quicker.

After running the above command you should now be able to restart your irb instance and re-run the test snippet described at the beginning of this post. This time you should get output looking similar to the following:

 => #<File:/var/folders/j_/9nxyjmd10js8g1sjx446vrsm0000gn/T/open-uri20120907-36935-4i4y64> 

Just like that your SSL woes are gone.

Finished Laying Bathroom Tile

by Andrew De Ponte (@cyphactor)

Well, it has been a while since I posted any of my progress on the house. So here is a little update.

This weekend I finished laying all the tile in the bathroom shower, the bullnosed tiles for the baseboard and setting the shelf in the shower.

I also bought a wash tub for the garage. I did this so I can scrub my hands and my tools without having to come inside the house. Tonight I constructed the pipe system to connect from the wash tub to the existing drain system in the garage.

Anyways, my next steps for the bathroom are to clean all the tiles and make sure the grout paths are clear. Once, I have cleaned up the tile and grout paths I will be ready to grout the tiles. I will be using a polyblend sanded grout and a color matched caulk in the inner corners of the shower. I was told that I should use the caulk in the inner corners because the walls expand and shrink as the temperature changes and it usually causes grout in the inner corners to crack. Hence, use caulk because it is more flexible and can absorb the expansion and contraction of the walls.

I feel pretty good about all the progress I have made this weekend and can’t wait for the shelf to finish setting so that I can clean up all the tile and get to grouting. The vision of the bathroom is finally starting to come together and I can’t wait to get it finished.

Till next time.

Sublime Text 2 Guard Plugin Updates

by Andrew De Ponte (@cyphactor)

I woke up early this morning and thought it was time for a little sublime_guard love. I went through and tackled all of the syntax highlighting issues. This included the following issues (#27, #30, #31, #38, #43, #29).

I also cleaned up a number of tickets that were lying around and had either been completed already or were tickets that were invalid.

I also started a branch for adding python3 support to the plugin. The branch is named python3_support. I would love it if anyone out there in the ether would grab that branch, test it out, and give me some feedback.

Anyways, I hope you guys enjoy the updates. As usual if you installed from Package Control just restart Sublime Text 2. If you installed manually then just pull the latest version down with Git.

See you all next time.

Ruby and Rails Mountain Lion Hiccups

by Andrew De Ponte (@cyphactor)

So when Mac OS X Mountain Lion was released a few days ago I jumped on upgrading and got switched over as soon as I could. My mentality for upgrading is that I would much rather deal with the pain of upgrading in smaller chunks when needed rather than waiting. Plus, I just like to be on the latest and greatest in terms of the tools I use for my job.

Anyways, below is going to be a listing of some of the hiccups that either I or other developers on my team have run into in terms of their Ruby and Rails development environment setups.

Git

Some of the devs on my team had Git installed via the git-osx-installer. These developers seemed to lose their Git installs when they upgraded. I was using a Homebrew install of Git and it worked just fine for me after upgrading. So be aware of what your situation is and resort to brew because it is awesome.

XCode 4.4

In order to build gems with the native exensions and just to have the basic development tools around I installed the latest XCode 4.4. Once installed I went to the preferences menu, in the download tab, and chose to install the Command Line Tools because that is really what I was looking for more than anything. I have read on other posts online that you can download the Command Line Tools alone and install just them. I personally chose to install XCode as I do use XCode and the native tools to work on iPhone/iPad app development as well.

gcc-4.2

The latest XCode now comes with clang/llvm which is a new C/C++/Objective-C compiler. The problem is that the Ruby language isn’t fully compatible with clang and llvm. Therefore, you need to install GCC 4.2 using Homebrew. GCC 4.2 is the latest version of the GCC compiler that apple provided before switching to clang/llvm. Anyways, you can install GCC 4.2 by doing the following with brew:

brew tap homebrew/dupes
brew install apple-gcc42

The above will install the apple gcc-4.2 in a side by side fashion with XCode. This means that it won’t mess up your existing XCode install like other solutions.

Once you install gcc-4.2 then you can install/reinstall your ruby version inside of RVM as needed.

Apache 2 (Web Sharing)

In the upgrade it seems that they have revamped the Sharing preference pane. In the process of this it seems that Apple has decided to remove the Web sharing component of this preference pane. Don’t worry though. Apache is still there and running. You just can’t start it and stop it from the preferences pane anymore. You can use the following commands instead.

sudo apachectl stop
sudo apachectl start
sudo apachectl restart

Note: When the upgrade happened it nuked all my /etc/apache2/users/ configs and all my other apache configs. So, if you have any custom apache configs as I did you should probably back them up before upgrading.

X11

It seems that another thing that was changed with the upgrade to Mac OS X Mountain Lion was that they removed the X11 that I had previously installed and seemed to no longer provide it. Thats ok though because XQuartz 2.7.2 is what you want and it is available freely at http://xquartz.macosforge.org/landing/. Just install that bad boy and follow the on screen instructions to reboot when it is done and you should be good to go in terms of X11.

ImageMagick

Before upgrading I had ImageMagick installed via Homebrew. After, the upgrade was finished my ImageMagick was exiting with failures about some dylib. To solve this problem I simply ran the following and I was back in running order with respect to ImageMagick:

brew upgrade imagemagick

Pygments

I use Pygments to handle syntax highlighting in my jekyll sites and it seemed to not be working after the upgrade. I believe this is because it is now using Python 2.7.2. To resolve this issue I just re-installed Pygments using the following:

sudo easy_install Pygments

Sublime Text 2 Guard Plugin Updates

by Andrew De Ponte (@cyphactor)

It has been a while since I have provided an update on my Sublime Text 2 Guard Plugin and I just made some changes so I figured I would make a quick post. The project has recently had a number of contributions which I will list in the changes below.

I have been completely stoked with the growing usage of this plugin as well as the abundance of contributions people have been making to the plugin. In this update there are a number of people that need to be called out with special thanks.

@diogomafra provided a Clear output when predefined text found feature. I am sure many users will find this feature a nice addition to smoothing out their workflow. Thank you for your contribution @diogomafra.

@chrislerum provided rbenv support. I know that this feature will be huge for a number of the users as this was a highly requestd feature. Thank you so much for your contribution @chrislerum.

@brandonblack provided the ability to function without bundler. This will allow users who aren’t using bundler to be able to use this plugin. I think this is a great addition as the more people we can get using this plugin the more feedback we can get. Hence, the better it will become. Thanks for your contribution @brandonblack.

@whitequark provided the basis for the Run all Tests & Show Guard Output feature. I know a number of developers who have been waiting for something like this to fit their personal workflow. Thank you very much for your contribution @whitequark.

A big thanks goes out to all the above listed contributors and all of our prior contributors. Thank you all for helping make this a solid very useful plugin for the development community. As usual please make issues for any bugs or feature requsets you have at Sublime Text 2 Guard Plugin.