Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of OpenSSL::SSL::SSLError

I am trying to authenticate users with Facebook using OmniAuth. Initially, it was working, but along the way it just stopped working and started to give me this error message:

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

The same code works well for Twitter and I can't seem to understand why it doesn't work for Facebook. I have looked online for help, but I haven't been successful.

This is the link to the website I am building: http://www.bestizz.com/
And this url would give you the error message: http://www.bestizz.com/auth/facebook

like image 738
Eugene Avatar asked Apr 19 '11 03:04

Eugene


People also ask

Why am I getting certificate errors on all websites?

An SSL certificate error occurs when the browser cannot verify the SSL certificates returned by the server. When the error happens, the browser blocks the website and warns the user that the website cannot be trusted as shown below. These warnings will negatively impact the user's trust in your website.

What is the common reason why certificates become invalid and show warning messages?

An invalid SSL Certificate can occur when you try installing an SSL/TLS certificate on the server, but the certificate details are not correct. The installed certificate has been purchased illegally, or it's revoked. There's a broken certificate chain of trust.

What is SSL certificate Python requests?

Requests verifies SSL certificates for HTTPS requests, just like a web browser. SSL Certificates are small data files that digitally bind a cryptographic key to an organization's details. Often, a website with a SSL certificate is termed as secure website.


2 Answers

Ruby cannot find any root certificates. Here is an option for debugging purposes. Put following code at the begining of your script:

   require 'openssl'    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE 
like image 117
RAJ Avatar answered Oct 02 '22 06:10

RAJ


Add the following code to config/initializers/fix_ssl.rb

require 'open-uri' require 'net/https'  module Net   class HTTP     alias_method :original_use_ssl=, :use_ssl=      def use_ssl=(flag)       self.ca_file = "/etc/pki/tls/certs/ca-bundle.crt"  # for Centos/Redhat       self.verify_mode = OpenSSL::SSL::VERIFY_PEER       self.original_use_ssl = flag     end   end end 

Note:

Many operating systems already come with a supplied certificate bundle. For example in Red Hat Enterprise Linux and CentOS it's installed in:

/etc/pki/tls/certs/ca-bundle.crt 

For Ubuntu its at:

/etc/ssl/certs/ca-certificates.crt 
like image 23
Amal Kumar S Avatar answered Oct 02 '22 06:10

Amal Kumar S