kumistatus/ssltools/__init__.py

8 lines
321 B
Python
Raw Normal View History

2016-03-16 15:49:56 +00:00
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")