« Setting up a Ruby on Rails server - Part 6 - Axigen easy mail server | Home | Rails 1.2 doesn’t support composite primary keys »

How to get Ruby OpenSSL to work on CentOS

By Nick | July 13, 2007

I recently needed the Ruby OpenSSL library to do some decoding and encoding. I had tested everything on Windows and there it worked without a glitch. But after moving my code to Linux CentOS it stopped working. I got the error: LoadError: no such file to load — openssl

After much searching I found the solution. This only works when you have installed Ruby from the source and is only tested with Ruby 1.8.4 (but probably also works with newer versions).

First you need to make sure openssl en openssl-devel are installed (yum list | grep openssl). If not, install them using yum install openssl and yum install openssl-devel. Both libraries are needed to compile the Ruby OpenSSL code. After that, locate the openssl folder in the Ruby source files (ruby-1.8.4/ext/openssl) and make sure you are in the folder, when you run the following commands:

ruby extconf.rb
make
make install

make install should write the compiled libraries to your Ruby folder. Open irb to check if it worked.

irb(main):001:0> require ‘openssl’
=> true

If it returns true you are good to go.

Topics: Uncategorized |

6 Responses to “How to get Ruby OpenSSL to work on CentOS”

  1. Arnaud MEURET Says:
    December 17th, 2007 at 8:43 pm

    Ruby 1.8.6 only requires openssl-devel to be installed prior to compiling on my CentOS 5 box.

    Plain ruby compilation with ./configure, make install perfectly locates openssl and compiles everything just fine.

    No need to go to ext/openssl.

  2. Jason Says:
    January 25th, 2008 at 7:21 pm

    If your running ruby 1.8.5 or newer, on centos 5 or newer, and your still having this issue you do not have to compile ruby from source. Just remove all ruby packages, make sure that your openssl and openssl-devel packages are in place and happy, and rebuild ruby. Works like a charm here.

  3. michaeleconomy Says:
    April 1st, 2008 at 8:18 am

    Thanks! that was exactly what i needed to know!

  4. Scott Whitmire Says:
    May 20th, 2008 at 5:18 pm

    This works for Ruby 1.8.6, too. Thank you!

  5. Isabelle Says:
    May 22nd, 2008 at 12:20 am

    tried this and it failed. Using CentOS, rails 1.8.6 local installation.

    I have checked I have both openssl and openssl-devel.

    I run ruby extconf.rb and get:

    === OpenSSL for Ruby configurator ===
    === Checking for system dependent stuff… ===
    checking for t_open() in -lnsl… no
    checking for socket() in -lsocket… no
    checking for assert.h… yes
    === Checking for required stuff… ===
    checking for openssl/ssl.h… no
    === Checking for required stuff failed. ===
    Makefile wasn’t created. Fix the errors above.

    I am not root on my machine and thus cannot fix openssl myself.

    Is there a way around this?

    thanks for any help you may provide.

  6. Isabelle Says:
    May 22nd, 2008 at 12:55 am

    this fixes my openssl problem:

    http://www.railsforum.com/viewtopic.php?pid=49227

Comments