def assert_fingerprint(cert, fingerprint):
 fingerprint = fingerprint.replace(':', '').lower()
 digest_length = len(fingerprint)
 hashfunc = HASHFUNC_MAP.get(digest_length)
 if (not hashfunc):
  raise SSLError('Fingerprint of invalid length: {0}'.format(fingerprint))
 fingerprint_bytes = unhexlify(fingerprint.encode())
 cert_digest = hashfunc(cert).digest()
 if (cert_digest != fingerprint_bytes):
  raise SSLError('Fingerprints did not match. Expected "{0}", got "{1}".'.format(fingerprint, hexlify(cert_digest)))

def assert_fingerprint ( cert , fingerprint ) : fingerprint = fingerprint . replace ( ':' , '' ) . lower ( ) digest_length = len ( fingerprint ) hashfunc = HASHFUNC_MAP . get ( digest_length ) if ( not hashfunc ) : raise SSLError ( 'Fingerprint of invalid length: {0}' . format ( fingerprint ) ) fingerprint_bytes = unhexlify ( fingerprint . encode ( ) ) cert_digest = hashfunc ( cert ) . digest ( ) if ( cert_digest != fingerprint_bytes ) : raise SSLError ( 'Fingerprints did not match. Expected "{0}", got "{1}".' . format ( fingerprint , hexlify ( cert_digest ) ) )
checks if given fingerprint matches the supplied certificate .