[Cryptography-dev] x509 Certificate Fingerprint Format
Alexander Nigl
python-cryptography at qu3.org
Tue Feb 12 06:39:42 EST 2019
Hi Gilbert,
I initially searched for a codec solution but this seems more like a
string formating exercise. Here is my short solution:
> cert = x509.load_pem_x509_certificate(pem_block, default_backend())
>
> hash_bytes = cert.fingerprint(hashes.SHA1())
> print(hash_bytes)
> b'v\xe1\x81\x9f\xad\xf0jU\xefK\x12j.\xf7C\xc2\xba\xe8\xa1Q'
hash = ":".join([hex(h)[2:].upper() for h in hash_bytes])
print(hash)
'76:E1:81:9F:AD:F0:6A:55:EF:4B:12:6A:2E:F7:43:C2:BA:E8:A1:51'
Regards
Alexander
More information about the Cryptography-dev
mailing list