7 lines
321 B
Python
7 lines
321 B
Python
import datetime, OpenSSL, ssl
|
|
|
|
def getRemoteCert(host, port):
|
|
return ssl.get_server_certificate((host, port))
|
|
|
|
def getRemoteExpiry(host,port):
|
|
return datetime.datetime.strptime(str(OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, getRemoteCert(host, port)).get_notAfter().decode("UTF-8")), "%Y%m%d%H%M%SZ")
|