How to fix Ruby error: Unsupported digest algorithm (sha256).

This is a note to myself because this has happened to me more than once. I’m posting it publicly in case it helps others, too.

This is for people on a Mac, using rvm and homebrew.

I ran across this with the very nice Sucker gem, which lets you easily access the Amazon Product Advertising API. Amazon requires SHA-256 in its API calls, which is where my trouble began.

If your Ruby app got this error message in openssl/digest.rb:55:

Unsupported digest algorithm (sha256).

it’s because when you installed (compiled) Ruby, you linked in an older version of the openssl library.

I Like Stuff that Finally Worked

Here’s how I fixed it:

brew install openssl
rvm remove 1.8.7
rvm install 1.8.7 --with-openssl-dir=/usr/local/Cellar/openssl/0.9.8o/

To test it, run this in the Terminal:

ruby -ropenssl -e 'p"sha256")'

If you don’t get an error message, it worked.

Things That Didn’t Work

Installing and building openssl from source ( did not work.

Installing the openssl rvm package and removing+reinstalling ruby did not work.

What finally worked was the steps above. Woo hoo!

By the way, I did not have to upgrade to Snow Leopard.

What about Ruby 1.9.2?

I still haven’t gotten it working in Ruby 1.9.2. I run this:

rvm install 1.9.2 --with-openssl-dir=/usr/local/Cellar/openssl/0.9.8o/

and I get this output:

ruby-1.9.2-p136 - #fetching
ruby-1.9.2-p136 - #extracted to /Users/Brian/.rvm/src/ruby-1.9.2-p136 (already extracted)
ruby-1.9.2-p136 - #configuring
ruby-1.9.2-p136 - #compiling
Error running 'make ', please read /Users/Brian/.rvm/log/ruby-1.9.2-p136/make.log
There has been an error while running make. Halting the installation.

So I go look in make.log and I see this at the end:

Generating RDoc documentation
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb  ./tool/runruby.rb --extout=.ext  -- "./bin/rdoc" --no-force-update --all --ri --op ".ext/rdoc"  "."
/Users/Brian/.rvm/gems/ruby-1.8.7-p330/gems/rdoc-3.4/lib/rdoc/rdoc.rb:79: warning: already initialized constant GENERATORS
uh-oh! RDoc had a problem:
undefined method `coverage_report' for #<RDoc::Options:0x7841a0>

Does anyone know how to fix it?

9 thoughts on “How to fix Ruby error: Unsupported digest algorithm (sha256).”

  1. Got the following from

    01-29-11 20:13:28 ~ ()ruby-1.9.2-p136
    ->rvm package install readline
    Fetching readline-5.2.tar.gz to /Users/macajueli/.rvm/archives
    Extracting readline-5.2.tar.gz to /Users/macajueli/.rvm/src
    Applying patch ‘/Users/macajueli/.rvm/patches/readline-5.2/shobj-conf.patch’…
    Configuring readline in /Users/macajueli/.rvm/src/readline-5.2.
    Compiling readline in /Users/macajueli/.rvm/src/readline-5.2.
    Installing readline to /Users/macajueli/.rvm/usr
    Fetching readline-6.0.tar.gz to /Users/macajueli/.rvm/archives
    Extracting readline-6.0.tar.gz to /Users/macajueli/.rvm/src
    Configuring readline in /Users/macajueli/.rvm/src/readline-6.0.
    Compiling readline in /Users/macajueli/.rvm/src/readline-6.0.
    Installing readline to /Users/macajueli/.rvm/usr
    ->rvm uninstall 1.9.2
    Removing /Users/macajueli/.rvm/rubies/ruby-1.9.2-p136…
    01-29-11 20:13:51 ~ ()
    ->rvm install 1.9.2 –with-readline-dir=$rvm_path/usr
    /Users/macajueli/.rvm/rubies/ruby-1.9.2-p136, this may take a while depending on your cpu(s)…

    ruby-1.9.2-p136 – #fetching
    ruby-1.9.2-p136 – #extracted to /Users/macajueli/.rvm/src/ruby-1.9.2-p136 (already extracted)
    ruby-1.9.2-p136 – #configuring
    ruby-1.9.2-p136 – #compiling
    ruby-1.9.2-p136 – #installing
    ruby-1.9.2-p136 – updating #rubygems for /Users/macajueli/.rvm/gems/ruby-1.9.2-p136@global
    ruby-1.9.2-p136 – updating #rubygems for /Users/macajueli/.rvm/gems/ruby-1.9.2-p136
    ruby-1.9.2-p136 – adjusting #shebangs for (gem).
    ruby-1.9.2-p136 – #importing default gemsets (/Users/macajueli/.rvm/gemsets/)
    Install of ruby-1.9.2-p136 – #complete
    01-29-11 20:18:50 ~ ()ruby-1.9.2-p136
    ->rvm 1.9.2
    01-29-11 20:39:44 ~ ()ruby-1.9.2-p136
    ->ruby -v
    ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]

    1. Thanks for the suggestion, Dave. But I still get the error with 1.9.2, “undefined method `coverage_report’ for #”

  2. I tried all the above and none worked. I ended up having to reinstall rails as a local single-user copy via the following:

    Installation of openssl — requires a new install of rails (failures with Unsupported digest algorithm (sha256)):
    1) Validate rvm and any existing copies of rails are gone. If no rvm is installed, skip this bit
    a) rvm list
    b) rvm remove 1.9.2 (should remove all copies that you have installed with rvm)
    2) Download and install homebrew –
    a) ruby -e “$(curl -fsSL”
    3) Install OpenSSL
    a) brew install openssl
    –> note which directory it has installed to (should be something like /usr/local/Cellar/openssl/0.9.8o)
    4) install rvm — followed for single user install which should overwrite system installs of rvm/ruby/rails
    a) bash < > ~/.bash_profile
    c) . ~/.bash_profile
    d) type rvm | head -1 # should return ‘rvm is a function’
    5) install ruby
    a) rvm install 1.9.2 –with-openssl-dir=/usr/local/Cellar/openssl/0.9.8o
    b) rvm use 1.9.2
    c) rvm use 1.9.2 –default
    d) ruby –version should return this:
    ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-darwin9.8.0]
    6) install rails & gems
    a) gem install rails –version =3.0.3
    b) env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
    c) bundle install
    7) validate
    a) ruby -ropenssl -e ‘p“sha256”)’ # should not error
    b) ruby -e “puts require(‘openssl’)” # should return true
    c) rails console and enter this:“sha256”)
    –> should not error and should return something like this:

    1. Wow, Josh, that must have sucked. I hate things like this that are super-hard to solve. It makes people just want to give up and switch to a different language.

      Thanks for posting your detailed notes.

      1. Yeah that was the last two nights of install, reinstall fun! The good news is this post comes up quite high in the search engine rankings so hopefully all the comments above are helpful to the next guy!
        The gist of it is simple however — get a standalone working rails install with openssl compiled into the binaries and you’re golden

Leave a Reply

Your email address will not be published. Required fields are marked *

Feel free to use <a>, <b>, <i>, <strong>, <em>, <strike>, <code>.

Code blocks:
[code language="ruby/javascript/html/css/sass/bash"]