Facebook ssl issue with Devise

Written by on May 9 2011

Working on Facebook authentication integration with Devise and hit an ssl snag when fb would call the oauth callback:

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):

What the?!

So I found this little tidbit on stackoverflow which solved the problem. The issue is that you need to tell Devise->OmniAuth->Faraday where your cert is. Here’s how to change your devise.rb initializer:

Before:
config.omniauth :facebook, ‘xx’, ‘yy’, {:scope => ‘publish_stream,offline_access,email’}

After:
config.omniauth :facebook, ‘xx’, ‘yy’, {:scope => ‘publish_stream,offline_access,email’, :client_options => {:ssl => {:ca_file => ‘/etc/pki/tls/certs/ca-bundle.crt’}}}
 

Meet
Steven

Hi I'm Steven,

I wrote the article you're reading... I lead the developers, write music, used to race motorcycles, and help clients find the right features to build on their product.

Get Blog Updates