def cert_fingerprint(self): if self._server_cert: with open(self._server_cert, "rb") as f: cert_data = read_pem_file(f) digest = hashlib.sha256() digest.update(cert_data) return digest.hexdigest() return None
def test_read_pem_file_chain(): with open(os.path.join(os.path.dirname(__file__), "..", "ca", "chain.crt"), mode="rb") as f: result = read_pem_file(f) assert result.endswith(b"\xc8\xae")
def test_read_pem_file(): with open(os.path.join(os.path.dirname(__file__), "..", "ca", "ca.crt"), mode="rb") as f: result = read_pem_file(f) assert result.startswith( b"0\x82\x05{0\x82\x03c\xa0\x03\x02\x01\x02\x02\x14")