faraday SSL error when using koala gem rails

299 Views Asked by At

I have this method of code here

def facebook 
  @facbeook ||= Koala::Facebook::API.new(oauth_token)
end

I am logged in to my facebook account I run in the console user.facebook.get_object("me") but i get this error

Faraday::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Railscast 361 shows to pass in the oauth_token you obtain from the user login. But doing so I get this error

I am not sure if it is part of my configuration or a general error from something else

EDIT I have found here in Koala docs koala about faraday and where you can set SSL certificate. Like this

Koala.http_service.http_options = { ssl: { ca_path: Rails.root.join("cacert.pem").to_s } }

Just need to figure out where to put

1

There are 1 best solutions below

0
Lee Eather On

Ok fix this by putting in initializer eg koala.rb

Koala.http_service.http_options = { ssl: { ca_file: Rails.root.join("cacert.pem").to_s } }

or you can do it on a per request basis like

u.facebook.get_object("me", {}, { ssl: { ca_file: Rails.root.join("cacert.pem").to_s } })