Normalize fingerprints to allow more formats.

https://github.com/Limnoria/Limnoria-doc/issues/76#issuecomment-198794341
This commit is contained in:
Valentin Lorentz 2016-03-20 10:28:33 +01:00
parent 9cd2170a14
commit 93feb71b66
1 changed files with 4 additions and 0 deletions

View File

@ -131,9 +131,13 @@ def isIPV6(s):
return False
normalize_fingerprint = lambda fp: fp.replace(':', '').lower()
FINGERPRINT_ALGORITHMS = ('md5', 'sha1', 'sha224', 'sha256', 'sha384',
'sha512')
def check_certificate_fingerprint(conn, trusted_fingerprints):
trusted_fingerprints = set(normalize_fingerprint(fp)
for fp in trusted_fingerprints)
cert = conn.getpeercert(binary_form=True)
for algorithm in FINGERPRINT_ALGORITHMS:
h = hashlib.new(algorithm)