HTTPS URL Server Certificate in Ruby

How to get https server certificate using Net :: HTTP or HTTPClient Ruby lib?

+4
source share
2 answers

I found a solution using HTTPClient lib

require 'rubygems' require 'httpclient' client = HTTPClient.new response = client.get("https://gmail.google.com") cert = response.peer_cert 

Make sure gemclient gem is installed

 sudo gem install httpclient 
+8
source

I do not think that you can do this with any of these libraries or even with more advanced libcurl and shells. But alternatively - if you have an openssl command-line tool, you can call it and analyze the output, the command you need is as follows:

openssl s_client -connect my.server.name:443

This will give you a complete dump of the certificate, as well as some analyzed information - the subject, issuer, etc.

0
source

All Articles