3

This is nearly a duplicate of:

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

but specific to a Rails 4 and Ruby 2 environment. I figure it is appropriate to make a new question because the solutions that worked on my machine for previous environments no longer appear to work after the updates to Rails and Ruby.

The Problem

When making a Net/HTTP SSL request to the tune of:

api_uri = URI("http://accounts.google.com/o/oauth2/token")
https = Net::HTTP.new(api_uri.host, api_uri.port)
https.use_ssl = true
https.ca_file = '/usr/local/etc/openssl/cert.pem' if Rails.env == "development"
https.request_get(api_uri.path)

I receive the

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol

error. I've tried out the solutions in the referenced question that worked in the previous environments, to no avail.

Community
  • 1
  • 1
Michael Pell
  • 1,416
  • 1
  • 14
  • 17

2 Answers2

0

Try setting the certificate in environment i.e ENV see it that help something like this

ENV['SSL_CERT_FILE'] = "your certificate path"
Viren
  • 5,812
  • 6
  • 45
  • 98
0

Looks like it a typo - it should be an https:// protocol in the URI on the first line (and not http://)

Kitebuggy
  • 89
  • 6