Mercurial > hg
comparison mercurial/sslutil.py @ 29225:b115eed11780
sslutil: use a dict for hanging hg state off the wrapped socket
I plan on introducing more state on the socket instance. Instead
of using multiple variables, let's just use one to minimize risk
of name collision.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 15 May 2016 11:25:07 -0700 |
parents | 7424f4294199 |
children | 33006bd6a1d7 |
comparison
equal
deleted
inserted
replaced
29224:7424f4294199 | 29225:b115eed11780 |
---|---|
169 # closed | 169 # closed |
170 # - see http://bugs.python.org/issue13721 | 170 # - see http://bugs.python.org/issue13721 |
171 if not sslsocket.cipher(): | 171 if not sslsocket.cipher(): |
172 raise error.Abort(_('ssl connection failed')) | 172 raise error.Abort(_('ssl connection failed')) |
173 | 173 |
174 sslsocket._hgcaloaded = caloaded | 174 sslsocket._hgstate = { |
175 'caloaded': caloaded, | |
176 } | |
175 | 177 |
176 return sslsocket | 178 return sslsocket |
177 | 179 |
178 def _verifycert(cert, hostname): | 180 def _verifycert(cert, hostname): |
179 '''Verify that cert (in socket.getpeercert() format) matches hostname. | 181 '''Verify that cert (in socket.getpeercert() format) matches hostname. |
339 'verified (check hostfingerprints or web.cacerts ' | 341 'verified (check hostfingerprints or web.cacerts ' |
340 'config setting)\n') % | 342 'config setting)\n') % |
341 (host, nicefingerprint)) | 343 (host, nicefingerprint)) |
342 return | 344 return |
343 | 345 |
344 if not sock._hgcaloaded: | 346 if not sock._hgstate['caloaded']: |
345 if strict: | 347 if strict: |
346 raise error.Abort(_('%s certificate with fingerprint %s not ' | 348 raise error.Abort(_('%s certificate with fingerprint %s not ' |
347 'verified') % (host, nicefingerprint), | 349 'verified') % (host, nicefingerprint), |
348 hint=_('check hostfingerprints or ' | 350 hint=_('check hostfingerprints or ' |
349 'web.cacerts config setting')) | 351 'web.cacerts config setting')) |