Posts Tagged ‘ ruby on rials ’

OmniAuth facebook/twiitter SSL certificate error

i have used Omniauth for facebook login . I followed this tutorial to integrate facebook login

I followed all the steps of that tutorial but after authorizing the app and when redirect to /auth/facebook/callback fails with:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

This error we get because Omniauth/Oauth wasn’t setting the ca_path variable for OpenSSL of their HTTP calls.OpenSSL did not find the root certificate for Facebook’s SSL certificate.As a result we got this error.

We can solve the issue by two ways .

  • One way is we can set SSL certificate path
  • anothe one is ignore the certificaiton verification

Let’s see what will we do if we want to ignore the certification:

  • you can fix this in CBA’s application-config.
  • Add the following line to your file config/omniauth.rb

So now config/omniauth.rb will be look like :

Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, "apikey", "secretkey"

what will we do to set the certification path :

take a look at this link ruby on rails and ssl error

    • sudo port install curl-ca-bundle
    • modify the config/omniauth.rb files
    • set ca_path in the client options
    • Rails.application.config.middleware.use OmniAuth::Builder do :
      facebook, FACEBOOK_KEY, FACEBOOK_SECRET, {:client_options => {:ssl => {:ca_path => "/opt/local/share/curl/curl-ca-bundle.crt"}}}

Hopefully this two ways can be solved the SSL certificate issue.