使用OpenSSl
代码语言:javascript复制from OpenSSL import crypto
# path表示证书路径,file_name表示证书文件名
cert_file = '/path/file_name/'
cert_file = '/path/to/your/certificate'
cert = crypto.load_certificate(crypto.FILETYPE_PEM, open(cert_file).read())
subject = cert.get_subject()
# 得到证书的域名
issued_to = subject.CN
issuer = cert.get_issuer()
# 得到证书颁发机构
issued_by = issuer.CN