Skip to content
Snippets Groups Projects
Commit 3e1374a3 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

manage custom https port | refs #27164

parent f96b99a5
No related branches found
No related tags found
No related merge requests found
......@@ -57,15 +57,24 @@ for s, d in conf_servers:
# the domain is not in the hosts file, the service is surely not installed
continue
conn = ssl.create_connection((v, 443))
# check if custom port is used
v_split = v.split(":")
if v_split > 1:
server_name = v_split[0]
port = int(v_split[1])
else:
server_name = v
port = 443
conn = ssl.create_connection((server_name, port))
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
sock = context.wrap_socket(conn, server_hostname=v)
sock = context.wrap_socket(conn, server_hostname=server_name)
cert = ssl.DER_cert_to_PEM_cert(sock.getpeercert(True))
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
not_after = x509.get_notAfter().decode('ascii')
expires = datetime.datetime.strptime(not_after, '%Y%m%d%H%M%SZ')
print('\nTLS cert for {} expires at {}'.format(v, expires.isoformat()))
print('\nTLS cert for {} expires at {}'.format(server_name, expires.isoformat()))
remaining = expires - datetime.datetime.utcnow()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment