13 lines
402 B
Python
13 lines
402 B
Python
# Get certificates from domains and make a similar chain.
|
|
|
|
import OpenSSL
|
|
import ssl
|
|
|
|
def get_server_cert(domain, port=443):
|
|
cert_pem = ssl.get_server_certificate((domain, port))
|
|
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert_pem)
|
|
for i in range(cert.get_extension_count()):
|
|
ext = cert.get_extension(i)
|
|
ext_name = ext.get_short_name()
|
|
if ext_name == "":
|
|
return cert
|