A
A
Andrey Baibek2020-03-12 14:53:49
ruby
Andrey Baibek, 2020-03-12 14:53:49

How to implement SSL validation of a domain certificate?

Greetings, how can you, having domains, find out information about their certificates, and, accordingly, check whether other SSL errors have expired or not. Verification should be carried out without third-party api and services. You can use openSSL. Can you "poke" where to draw resources?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Karasik, 2020-03-12
@AndreyBuyback

To start
openssl s_client -connect qna.habr.com:443
and start learning/parsing the relevant parts

S
Sergey Blokhin, 2020-03-12
@TITnet

require 'net/http'
require 'openssl'

domain_name = 'qna.habr.com'

uri = URI::HTTPS.build host: domain_name
response = Net::HTTP.start uri.host, uri.port, use_ssl: true
cert = response.peer_cert

# @return [Time] 
cert.not_after

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question