Reputation: 2879
I'm trying to implement OmniAuth for Facebook in tandem with AuthLogic. I'm currently getting the following error:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
I've tried the solution shown here: SSL Error OmniAuth in Ruby on Rails with no success. I'm getting the error (undefined local variable or method `config') when trying to start my server. I'm on a windows machine and have downloaded the cacert.pem file and placed it in the /config/ folder.
Here's the code I have in my /initialzers/omniauth.rb file:
Rails.application.config.middleware.use OmniAuth::Builder do
require "omniauth-facebook"
if RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
ca_file = File.expand_path Rails.root.join("config", "cacert.pem")
ssl_options = {}
ssl_options[:ca_path] = '/etc/ssl/certs' if Rails.env.staging?
ssl_options[:ca_file] = ca_file
config.omniauth :facebook, "MYAPPID", "MYAPPSECRET", # "APP_ID", "APP_SECRET" your got from facebook app registration
:client_options => {:ssl => ssl_options}
else
config.omniauth :facebook, "MYAPPID", "MYAPPSECRET"
end
end
I've also seen posts referencing ca-certificate.crt instead of cacert.pem, which of these is it looking for? I'm a little lost on what to try next so any help is greatly appreciated!
Upvotes: 0
Views: 788
Reputation: 26
Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, FACEBOOK_KEY, FACEBOOK_SECRET, {:client_options => {:ssl => {:ca_path => "/etc/ssl/certs"}}} end
This is not the standard way but it may help you on development setup by disabling ssl verification.
if Rails.env.development? OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE end
Upvotes: 0
Reputation: 2708
The (undefined local variable or method 'config') error you are getting here is because there is no 'config' variable defined in your file. The post you extracted it from was configuring devise which has
Devise.setup do |config| ... end
block so the variable config can be used there.
Get rid of the config variable so it would be something like this,
Rails.application.config.middleware.use OmniAuth::Builder do
if RbConfig::CONFIG["host_os"] =~ /mingw|mswin/
ca_file = File.expand_path Rails.root.join("config", "cacert.pem")
ssl_options = {}
ssl_options[:ca_path] = '/etc/ssl/certs' if Rails.env.staging?
ssl_options[:ca_file] = ca_file
provider :facebook, "MYAPPID", "MYAPPSECRET", # "APP_ID", "APP_SECRET" your got from facebook app registration
:client_options => {:ssl => ssl_options}
else
provider :facebook, "MYAPPID", "MYAPPSECRET"
end
end
Upvotes: 2