finding expiration dates on ssl certificates

D

dusty

Here is a way to find information about an ssl certificate. I
primarily wanted to do this as an easy way to check the expiration
date. In case anyone else is looking to do something similar, I
thought I'd share.

require 'net/https'
uri = URI.parse("https://www.somesite.com")
http = Net::HTTP.new(uri.host,uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |h|
@cert = h.peer_cert
end
puts <<EOD
Subject: #{@cert.subject}
Issuer: #{@cert.issuer}
Serial: #{@cert.serial}
Issued: #{@cert.not_before}
Expires: #{@cert.not_after}
EOD
 
R

Richard Conroy

Here is a way to find information about an ssl certificate. I
primarily wanted to do this as an easy way to check the expiration
date. In case anyone else is looking to do something similar, I
thought I'd share.

<snip>

Nice! This is going to come in handy for me soon. Thanks for
pre-empting my google search.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top