I would use
conn = ssl.create_default_context().wrap_socket(socket.socket(socket.AF_INET), server_hostname=hostname) conn.connect((hostname, 443)) cert = conn.getpeercert() print(cert['notAfter'])
I would use
to test it.