How to Fix Facebook and Omniauth Issue: SSLError

If you use Facebook and Omniauth, you’ll find that recent updates which I think more to do with Ruby has caused some issue.

Read about Ruby 1.9 and the SSL error.

The exact error I got is:

A OpenSSL::SSL::SSLError occurred in #:

  SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
  /home/user/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:678:in `connect'

Encountered after upgrading to new version of omniauth.

Stackoverflow has been helpful for me to find the fix but had to read more about that certificate required.

Make sure to update config.

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :facebook, FACEBOOK_KEY, FACEBOOK_SECRET, {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}}
end

It wasn’t stated clearly on the posts but this all you need to get it working:

cd /etc/ssl/certs
sudo wget http://curl.haxx.se/ca/cacert.pem