How to get peer_cert for https request using Ruby?
How can I access peer_cert when making an SSL request?
I have updated my ruby ssl certificates with rvm osx-ssl-certs update all
I am trying to do
require 'httpclient'
c = HTTPClient.new
r = c.get( "https://gmail.com" )
puts r.peer_cert
But I keep getting
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: sslv3 alert handshake failure
or
OpenSSL::SSL::SSLError: hostname "gmail.com" does not match the server certificate
What does the first error mean? Is there a way to make it automatically set the version of the property?
I can download the data from the url using HTTParty and Farday, but in this case I don't know here to access the actual SSL certificate that was used.
source to share
You cannot get a peer certificate until you make a successful connection and you get an error about a successful connection. Have you updated to the latest httpclient? Many servers have changed their SSL handshake configurations in response to recent vulnerabilities, and a new httpclient has been released in response to the same, which should perhaps be compatible with new server configurations.
source to share