简体   繁体   中英

faraday SSL error when using koala gem rails

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

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 } })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM