mercurial/sslutil.py
changeset 35582 72b91f905065
parent 35369 c8ecd96cc357
child 36745 424994a0adfd
equal deleted inserted replaced
35581:154754d1f137 35582:72b91f905065
    15 import ssl
    15 import ssl
    16 
    16 
    17 from .i18n import _
    17 from .i18n import _
    18 from . import (
    18 from . import (
    19     error,
    19     error,
       
    20     node,
    20     pycompat,
    21     pycompat,
    21     util,
    22     util,
    22 )
    23 )
    23 
    24 
    24 # Python 2.7.9+ overhauled the built-in SSL/TLS features of Python. It added
    25 # Python 2.7.9+ overhauled the built-in SSL/TLS features of Python. It added
   806         return
   807         return
   807 
   808 
   808     # If a certificate fingerprint is pinned, use it and only it to
   809     # If a certificate fingerprint is pinned, use it and only it to
   809     # validate the remote cert.
   810     # validate the remote cert.
   810     peerfingerprints = {
   811     peerfingerprints = {
   811         'sha1': hashlib.sha1(peercert).hexdigest(),
   812         'sha1': node.hex(hashlib.sha1(peercert).digest()),
   812         'sha256': hashlib.sha256(peercert).hexdigest(),
   813         'sha256': node.hex(hashlib.sha256(peercert).digest()),
   813         'sha512': hashlib.sha512(peercert).hexdigest(),
   814         'sha512': node.hex(hashlib.sha512(peercert).digest()),
   814     }
   815     }
   815 
   816 
   816     def fmtfingerprint(s):
   817     def fmtfingerprint(s):
   817         return ':'.join([s[x:x + 2] for x in range(0, len(s), 2)])
   818         return ':'.join([s[x:x + 2] for x in range(0, len(s), 2)])
   818 
   819