kumistatus/ssltools/__init__.py
2016-03-16 16:49:56 +01:00

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")