Connecting using https to a server with a certificate signed by a CA I created Connecting using https to a server with a certificate signed by a CA I created ruby ruby

Connecting using https to a server with a certificate signed by a CA I created


I assume that your Tomcat doesn't like the protocol version that Ruby tries to negotiate. Ruby uses SSLv23 by default, but I've heard other cases where this was a problem for Java-based web servers. The error message you are getting indicates that the handshake fails while setting up the connection and trying to read the server's response. Try adding either

http.ssl_version = :TLSv1

or

http.ssl_version = :SSLv3

and see if that already helps.

If this does not fix the problem yet, it would be very interesting to see why your server rejects the connection attempt. Try running your Tomcat with -Djavax.net.debug=ssl and please post the relevant parts (connection information, exception stacktrace) as to why the attempt fails.


I am using ruby 1.9.3 and faced the same error while using nokogiri to parse some secure urls.

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: (null)

The above answer provided by emboss is correct but make sure the ssl error generated is this one that is mentioned above. I have followed the same and found a solution like this mentioned below.

uri = URI(url)http = Net::HTTP.new(uri.host, uri.port)http.use_ssl = truehttp.ssl_version = :SSLv3http.verify_mode = OpenSSL::SSL::VERIFY_PEERresponse = http.get(url)

now the response is having the correct html parsed for the secured url that is passed to the codes in the url .


Make sure that the your certificate file is in PEM format, not CRT (so the documentation for Net::HTTP in Ruby 1.9.3 says).

Update it looks like the documentation is not up to date, Ruby 1.9.3 will accept any kind of certificate.