sslutil: fix some edge cases in Python 3 support
authorAugie Fackler <augie@google.com>
Fri, 27 Apr 2018 00:05:46 -0400
changeset 37872 51a2f8d199c7
parent 37871 6574c81b6831
child 37873 bb1b15acfd06
sslutil: fix some edge cases in Python 3 support Detected by fixing up test-url.py on Python 3. Differential Revision: https://phab.mercurial-scm.org/D3467
mercurial/sslutil.py
--- a/mercurial/sslutil.py	Thu Apr 26 23:33:27 2018 -0400
+++ b/mercurial/sslutil.py	Fri Apr 27 00:05:46 2018 -0400
@@ -640,9 +640,9 @@
         return _('no certificate received')
 
     dnsnames = []
-    san = cert.get('subjectAltName', [])
+    san = cert.get(r'subjectAltName', [])
     for key, value in san:
-        if key == 'DNS':
+        if key == r'DNS':
             try:
                 if _dnsnamematch(value, hostname):
                     return
@@ -672,6 +672,7 @@
 
                     dnsnames.append(value)
 
+    dnsnames = [pycompat.bytesurl(d) for d in dnsnames]
     if len(dnsnames) > 1:
         return _('certificate is for %s') % ', '.join(dnsnames)
     elif len(dnsnames) == 1: