Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting SSL Error Using Koala with Devise & OmniAuth in a Rails 3 App

I'm building a Rails 3 app using Devise/OmniAuth, and Koala and I'm getting the following SSL error:

OpenSSL::SSL::SSLError in Users/omniauth callbacksController#facebook
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

The code that causes this error is:

@graph = Koala::Facebook::GraphAPI.new(@token)
@friends = @graph.get_connections("me", "friends")

I am using Devise with OmniAuth to perform authentication, which works. I then take the returned facebook token, and attempt to use it with Koala as shown above. That is what causes this error.

It's probably worth noting that I was receiving the same error with Devise & OmniAuth initially. There are a few topics about this error, and I was able to solve it, by setting up my config/initialisers/devise.rb with,

config.omniauth :facebook, APPID, APPKEY, {:client_options => {:ssl => {:ca_file =>  "/opt/local/share/curl/curl-ca-bundle.crt"}}} 

I am guessing that I need to supply a similar configuration for Koala so that it knows where to retrieve the local ca_file. I can't find any indication of how to do so in the documentation though. Any ideas on how to do this, or how to avoid the error in general?

My dev environment is OSX.

like image 749
vansan Avatar asked May 25 '11 15:05

vansan


2 Answers

From the Koala repo https://github.com/arsduo/koala

You can set this in a Koala initializer which will set this option globally

/config/initializers/koala.rb

Koala.http_service.http_options = {
  :ssl => { :ca_path => "/etc/ssl/certs" }
}
like image 173
skyw00lker Avatar answered Nov 07 '22 09:11

skyw00lker


As I found on this thread you can set your options in your environment file (or in the class where you're using the gem) the following option:

Koala.http_service.ca_file = '/path/to/some/ca-certificate.crt'
like image 1
innonate Avatar answered Nov 07 '22 11:11

innonate