comparison mercurial/sslutil.py @ 35582:72b91f905065

py3: use node.hex(h.digest()) instead of h.hexdigest() hashlib.sha1.hexdigest() returns str on Python 3. Differential Revision: https://phab.mercurial-scm.org/D1792
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 29 Dec 2017 05:25:27 +0530
parents c8ecd96cc357
children 424994a0adfd
comparison
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