comparison mercurial/sslutil.py @ 45942:89a2afe31e82

formating: upgrade to black 20.8b1 This required a couple of small tweaks to un-confuse black, but now it works. Big formatting changes come from: * Dramatically improved collection-splitting logic upstream * Black having a strong (correct IMO) opinion that """ is better than ''' Differential Revision: https://phab.mercurial-scm.org/D9430
author Augie Fackler <raf@durin42.com>
date Fri, 27 Nov 2020 17:03:29 -0500
parents 8f50dc096cf4
children 59fa3890d40a
comparison
equal deleted inserted replaced
45941:346af7687c6f 45942:89a2afe31e82
225 225
226 return s 226 return s
227 227
228 228
229 def commonssloptions(minimumprotocol): 229 def commonssloptions(minimumprotocol):
230 """Return SSLContext options common to servers and clients. 230 """Return SSLContext options common to servers and clients."""
231 """
232 if minimumprotocol not in configprotocols: 231 if minimumprotocol not in configprotocols:
233 raise ValueError(b'protocol value not supported: %s' % minimumprotocol) 232 raise ValueError(b'protocol value not supported: %s' % minimumprotocol)
234 233
235 # SSLv2 and SSLv3 are broken. We ban them outright. 234 # SSLv2 and SSLv3 are broken. We ban them outright.
236 options = ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 235 options = ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3
615 pat = re.compile(br'\A' + br'\.'.join(pats) + br'\Z', re.IGNORECASE) 614 pat = re.compile(br'\A' + br'\.'.join(pats) + br'\Z', re.IGNORECASE)
616 return pat.match(hostname) is not None 615 return pat.match(hostname) is not None
617 616
618 617
619 def _verifycert(cert, hostname): 618 def _verifycert(cert, hostname):
620 '''Verify that cert (in socket.getpeercert() format) matches hostname. 619 """Verify that cert (in socket.getpeercert() format) matches hostname.
621 CRLs is not handled. 620 CRLs is not handled.
622 621
623 Returns error message if any problems are found and None on success. 622 Returns error message if any problems are found and None on success.
624 ''' 623 """
625 if not cert: 624 if not cert:
626 return _(b'no certificate received') 625 return _(b'no certificate received')
627 626
628 dnsnames = [] 627 dnsnames = []
629 san = cert.get('subjectAltName', []) 628 san = cert.get('subjectAltName', [])