def list_hosts(self):
hosts = {}
for csr_file in os.listdir(self.csr_path):
with open(os.path.join(self.csr_path, csr_file), 'rb') as f:
csr = x509.load_pem_x509_csr(f.read(), default_backend())
hosts[csr.subject.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value] = {
'key_fingerprint': rsa_key_fingerprint(csr.public_key()),
'cert_fingerprint': None,
'status': 'pending',
}
for crt_file in os.listdir(self.crt_path):
with open(os.path.join(self.crt_path, crt_file), 'rb') as f:
crt = x509.load_pem_x509_certificate(f.read(), default_backend())
revoked = revoked_cert(crt, self.crl)
if revoked:
status = 'revoked'
else:
status = 'authorized'
hosts[crt.subject.get_attributes_for_oid(NameOID.COMMON_NAME)[0].value] = {
'key_fingerprint': rsa_key_fingerprint(crt.public_key()),
'cert_fingerprint': x509_cert_fingerprint(crt),
'status': status,
}
return hosts
评论列表
文章目录