mercurial/sslutil.py
changeset 29341 0d83ad967bf8
parent 29334 ecc9b788fd69
child 29389 98e8313dcd9e
equal deleted inserted replaced
29340:ae92c3eee88e 29341:0d83ad967bf8
     7 # This software may be used and distributed according to the terms of the
     7 # This software may be used and distributed according to the terms of the
     8 # GNU General Public License version 2 or any later version.
     8 # GNU General Public License version 2 or any later version.
     9 
     9 
    10 from __future__ import absolute_import
    10 from __future__ import absolute_import
    11 
    11 
       
    12 import hashlib
    12 import os
    13 import os
    13 import ssl
    14 import ssl
    14 import sys
    15 import sys
    15 
    16 
    16 from .i18n import _
    17 from .i18n import _
   386         return
   387         return
   387 
   388 
   388     # If a certificate fingerprint is pinned, use it and only it to
   389     # If a certificate fingerprint is pinned, use it and only it to
   389     # validate the remote cert.
   390     # validate the remote cert.
   390     peerfingerprints = {
   391     peerfingerprints = {
   391         'sha1': util.sha1(peercert).hexdigest(),
   392         'sha1': hashlib.sha1(peercert).hexdigest(),
   392         'sha256': util.sha256(peercert).hexdigest(),
   393         'sha256': hashlib.sha256(peercert).hexdigest(),
   393         'sha512': util.sha512(peercert).hexdigest(),
   394         'sha512': hashlib.sha512(peercert).hexdigest(),
   394     }
   395     }
   395 
   396 
   396     def fmtfingerprint(s):
   397     def fmtfingerprint(s):
   397         return ':'.join([s[x:x + 2] for x in range(0, len(s), 2)])
   398         return ':'.join([s[x:x + 2] for x in range(0, len(s), 2)])
   398 
   399