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

Vikash picture Vikash · Dec 24, 2010 · Viewed 257.9k times · Source

I am using Authlogic-Connect for third party logins. After running appropriate migrations, Twitter/Google/yahoo logins seem to work fine but the facebook login throws exception:

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

The dev log shows

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
  app/controllers/users_controller.rb:37:in `update'

Please suggest..

Answer

Erik G. picture Erik G. · May 12, 2011

I ran into a similar problem when trying to use the JQuery generator for Rails 3

I solved it like this:

  1. Get the CURL Certificate Authority (CA) bundle. You can do this with:

    • sudo port install curl-ca-bundle [if you are using MacPorts]
    • or just pull it down directly wget http://curl.haxx.se/ca/cacert.pem
  2. Execute the ruby code that is trying to verify the SSL certification: SSL_CERT_FILE=/opt/local/etc/certs/cacert.pem rails generate jquery:install. In your case, you want to either set this as an environment variable somewhere the server picks it up or add something like ENV['SSL_CERT_FILE'] = /path/to/your/new/cacert.pem in your environment.rb file.

You can also just install the CA files (I haven't tried this) to the OS -- there are lengthy instructions here -- this should work in a similar fashion, but I have not tried this personally.

Basically, the issue you are hitting is that some web service is responding with a certificate signed against a CA that OpenSSL cannot verify.