TomiiPomii
TomiiPomii

Reputation: 23

How to check if a domain has a ssl certificate in python?

So, I have a problem and 2 hours of research haven't helped.

I want to write a method that will return me a Boolean if a web-domain(e.g. "google.com", without http/s) has an ssl-certificate.

I have a big csv of domain names, which I need to process and check if the domains have a ssl-certificate, is there a method maybe in pythons ssl module?

Thank you for your help, TomiiPomii.

Upvotes: 1

Views: 1631

Answers (1)

Nastor
Nastor

Reputation: 638

By using module ssl you can call ssl.get_server_certificate((host, port)) to retrieve SSL of specified host in PEM format. You will then have to parse the PEM file to actually retrieve the certificate values, but if you only care about the website having or not having it, simply check the return value.

Upvotes: 1

Related Questions