Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPS URL server certificate in Ruby

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

like image 558
Chandra Patni Avatar asked Feb 28 '23 21:02

Chandra Patni


1 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 you have httpclient gem installed

sudo gem install httpclient
like image 67
Chandra Patni Avatar answered Mar 05 '23 18:03

Chandra Patni