def load_pki(self, cert_path: str, cert_pass=None):
"""
??? ??
:param cert_path: ??? ??
:param cert_pass: ??? ????
"""
ca_cert_file = join(cert_path, self.CERT_NAME)
ca_pri_file = join(cert_path, self.PRI_NAME)
# ???/??? ??
with open(ca_cert_file, "rb") as der:
cert_bytes = der.read()
self.__ca_cert = x509.load_pem_x509_certificate(cert_bytes, default_backend())
with open(ca_pri_file, "rb") as der:
private_bytes = der.read()
try:
self.__ca_pri = serialization.load_pem_private_key(private_bytes, cert_pass, default_backend())
except ValueError:
logging.debug("Invalid Password")
# ??? ? ? ??
sign = self.sign_data(b'TEST')
if self.verify_data(b'TEST', sign) is False:
logging.debug("Invalid Signature(Root Certificate load test)")
评论列表
文章目录