mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-10-17 17:37:22 +02:00
Normalize fingerprints to allow more formats.
https://github.com/Limnoria/Limnoria-doc/issues/76#issuecomment-198794341
This commit is contained in:
parent
9cd2170a14
commit
93feb71b66
@ -131,9 +131,13 @@ def isIPV6(s):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
normalize_fingerprint = lambda fp: fp.replace(':', '').lower()
|
||||||
|
|
||||||
FINGERPRINT_ALGORITHMS = ('md5', 'sha1', 'sha224', 'sha256', 'sha384',
|
FINGERPRINT_ALGORITHMS = ('md5', 'sha1', 'sha224', 'sha256', 'sha384',
|
||||||
'sha512')
|
'sha512')
|
||||||
def check_certificate_fingerprint(conn, trusted_fingerprints):
|
def check_certificate_fingerprint(conn, trusted_fingerprints):
|
||||||
|
trusted_fingerprints = set(normalize_fingerprint(fp)
|
||||||
|
for fp in trusted_fingerprints)
|
||||||
cert = conn.getpeercert(binary_form=True)
|
cert = conn.getpeercert(binary_form=True)
|
||||||
for algorithm in FINGERPRINT_ALGORITHMS:
|
for algorithm in FINGERPRINT_ALGORITHMS:
|
||||||
h = hashlib.new(algorithm)
|
h = hashlib.new(algorithm)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user