2013-01-03 00:54:54 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import sys
|
|
|
|
sys.path.insert(0, "../../")
|
2014-08-16 13:53:07 +00:00
|
|
|
from netlib import tcp
|
|
|
|
|
|
|
|
|
|
|
|
def get_remote_cert(host, port, sni):
|
|
|
|
c = tcp.TCPClient((host, port))
|
|
|
|
c.connect()
|
|
|
|
c.convert_to_ssl(sni=sni)
|
|
|
|
return c.cert
|
2013-01-03 00:54:54 +00:00
|
|
|
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
port = int(sys.argv[2])
|
|
|
|
else:
|
|
|
|
port = 443
|
2014-08-16 13:53:07 +00:00
|
|
|
if len(sys.argv) > 3:
|
|
|
|
sni = sys.argv[3]
|
|
|
|
else:
|
|
|
|
sni = None
|
2013-01-03 00:54:54 +00:00
|
|
|
|
2014-08-16 13:53:07 +00:00
|
|
|
cert = get_remote_cert(sys.argv[1], port, sni)
|
2016-04-14 05:34:28 +00:00
|
|
|
print("CN:", cert.cn)
|
2013-01-03 00:54:54 +00:00
|
|
|
if cert.altnames:
|
2016-04-14 05:34:28 +00:00
|
|
|
print("SANs:")
|
2013-01-03 00:54:54 +00:00
|
|
|
for i in cert.altnames:
|
2016-04-14 05:34:28 +00:00
|
|
|
print("\t", i)
|