SSL Error while using rpxnow - ruby-on-rails

I am using RPX for OpenID Authentication. I am getting the following error. It happens only in windows. It works perfectly in Mac. Can someone please guide me to solve this error.
OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server c ertificate B: certificate verify failed)

adding http.verify_mode = OpenSSL::SSL::VERIFY_NONE to the function where we check the openid rectifies the error.

Related

OpenSSL::SSL::SSLError with Ruby's open method

I'm trying to get an https page with Ruby's open method:
response = open("https://example.com", 'User-Agent' => 'somebot').read
Sometimes it succeeds, but sometimes I get this error:
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed
from /usr/local/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock'
What's the reason this is happening and how come for some websites it works and for some it doesn't?
It's in the error message:
error: certificate verify failed
When you connect to some server using secure connection (https), all certificates in the certificate chain are checked for their validity up to the root certificate. If any of the certificates in the chain does not pass validity or the root certificate is not trusted root certificate, you get that error.
If you are on OSX and use RVM, see this readme. Alternatively, read about the issue here.

Learning Ruby on rails and getting excon SSL errors

I have tried researching this, and have no idea where to even look in my application to fix this error. I have been taking a course on Udemy and I am trying to use Google Cloud storage to upload images. When I add an image into a new record and try to save I receive this error.
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) Unable to verify certificate.
This may be an issue with the remote host or with Excon. Excon has certificates bundled, but these can be customized.Excon.defaults[:ssl_ca_path] = path_to_certs, ENV['SSL_CERT_DIR'] = path_to_certs, Excon.defaults[:ssl_ca_file] = path_to_file, ENV['SSL_CERT_FILE'] = path_to_file, Excon.defaults[:ssl_verify_callback] = callback (see OpenSSL::SSL::SSLContext#verify_callback), or Excon.defaults[:ssl_verify_peer] = false (less secure).

Issues making API requests to discourse instance from Heroku and locally using discourse_api gem

Been banging my head against this and need to bounce thoughts against someone else. I keep getting locally:
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed
I get on heroku:
openssl::ssl::sslerror: ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed
My discourse instance has a SSL certificate from DNSimple, so that is all working perfectly. On heroku, since I just have a rails API, I opted not to get an SSL cert for that since heroku already provides you with one, and just use the URL from your heroku instance.
Now, I am able to use a Advanced Rest Client (Chrome extension) and make requests to my discourse instance no problem. Here is some code that I am using with the discourse_api gem.
discourse_client = DiscourseApi::Client.new('https://community.desta.co')
discourse_client.api_key = ENV['COMMUNITY_API_KEY']
# path to heroku cert, which I verified exists through `heroku run bash`
discourse_client.ssl(ca_file: '/usr/lib/ssl/certs/ca-certificates.crt')
discourse_client.api_username = 'system'
Maybe I'm misunderstanding certificates? Please help! Thanks
For anyone that may have this issue, I was able to fix it. I tested my SSL config at https://www.ssllabs.com/ssltest/analyze.html and realized I didn't have any intermediate certificates along with my primary certificate :(. Definitely overlooked that one, hope it helps anyone.

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed

I have Rails API server hosted on Heroku, which makes an asynchronous POST request to a callback url specified in an initial API request by the client.
I have a problem when I try to POST to one of my clients' webapp over SSL.
connection = Faraday::Connection.new('https://subdomain.some_client.com', ssl: { ca_file: '/usr/lib/ssl/certs/ca-certificates.crt' })
connection.get '/test'
The following throws an error:
Faraday::Error::ConnectionFailed: SSL_connect returned=1 errno=0 state=error: certificate verify failed
However, if I post to another server over HTTPS, for example google, it works fine
connection = Faraday::Connection.new('https://www.google.com', ssl: { ca_file: '/usr/lib/ssl/certs/ca-certificates.crt' })
connection.get '/'
Does this mean the fault is on the client's SSL configuration? and if so, how can I assist them in debugging the problem?
UPDATE:
I can cURL POST to the client's webapp without problems, it's only when I do it through ruby's HTTP libraries it fails
Much appreciated
Thanks
My guess is that there is a problem with the SSL cert for your client's web app. Perhaps there is a certificate that is out of date or invalid. You could try this answer.
If you need to get around this (but probably not a good permanent solution, because of the potential security hole) you should be able to turn off the certificate verification by putting this before Bundler.require in your application.rb:
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

Who reads the value of ENV['SSL_CERT_FILE']?

I used to receive the following error:
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
from C:/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:678:in `connect'
after reading through this, I discovered that the fix is to download the cacert.pem file from here. The post recommends doing something like this:
ENV['SSL_CERT_FILE'] = File.join(File.dirname(__FILE__),"cacert.pem")
And, indeed, this solves the problem. However, who reads the value of SSL_CERT_FILE? Altering the environment doesn't seem like "the Ruby way" of doing it. I'm looking for a solution that could work with both Rails and Sinatra.
The openssl library uses the SSL_CERT_FILE environment variable.

Resources