How to get these stats in a dataframe for multiple domains. ex : google.com , nyu.edu
expected_output :
name expiry date status
google.com Wednesday, 12 August 2020 at 17:30:48 active
nyu.edu expired/No Cert expired/No Cert
tried this :
import ssl, socket
import pandas as pd
hostname =['google.com','nyu.edu']
datas=[]
for i in hostname:
ctx = ssl.create_default_context()
with ctx.wrap_socket(socket.socket(), server_hostname=i) as s:
s.connect((i, 443))
cert = s.getpeercert()
issued_to = subject['commonName']
notAfter=cert['notAfter']
data=[{"name":issued_to},{"expiry":notAfter}]
datas.append(data)
df = pd.DataFrame(datas)
Tried this got this can't figure out which certs are expired and which are not.