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

I am building a Rails 3 application using Devise / OmniAuth and Koala and I get 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 

Code causing this error:

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

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

It may be worth noting that I was getting the same error with Devise and OmniAuth initially. There are several topics about this error, and I was able to solve it by setting 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 assume that I need to provide a similar configuration for Koala so that it knows where to get the local ca_file. However, I cannot find any guidance on how to do this in the documentation. Any ideas on how to do this, or how to avoid a mistake altogether?

My dev is OSX.

+6
source share
3 answers

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

You can set this in the Koala initializer, which will set this parameter globally

/config/initializers/koala.rb

 Koala.http_service.http_options = { :ssl => { :ca_path => "/etc/ssl/certs" } } 
+5
source

As I found in this thread , you can set your parameters in your environment file (or in the class in which you use the gem) the following option:

 Koala.http_service.ca_file = '/path/to/some/ca-certificate.crt' 
+1
source

I found this solution useful: put it in your environment configuration file

(Koala :: HTTPService.http_options [: ssl] || = {}) [: ca_path] = '/ path / to / ca / โ€‹โ€‹folder' (Koala :: HTTPService.http_options [: ssl] || = {} ) [: ca_file] = '/ path / to / ca / โ€‹โ€‹file'

you can get the path by typing

openssl version -a

and extracting the path from the result

sources:
https://github.com/arsduo/koala/issues/130
https://github.com/technoweenie/faraday/wiki/Setting-up-SSL-certificates

0
source

Source: https://habr.com/ru/post/889012/


All Articles