[PATCH 3 of 6] sslutil: use a dict for hanging hg state off the wrapped socket
Gregory Szorc
gregory.szorc at gmail.com
Sun May 15 18:57:20 UTC 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1463336707 25200
# Sun May 15 11:25:07 2016 -0700
# Node ID f139b7d229a5d0d99c8d372e81ffaa053b3c3f77
# Parent 41885a60598f5d03437d8e481d48b45d411614a1
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.
diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py
--- a/mercurial/sslutil.py
+++ b/mercurial/sslutil.py
@@ -166,17 +166,19 @@ def wrapsocket(sock, keyfile, certfile,
sslsocket = sslcontext.wrap_socket(sock, server_hostname=serverhostname)
# check if wrap_socket failed silently because socket had been
# closed
# - see http://bugs.python.org/issue13721
if not sslsocket.cipher():
raise error.Abort(_('ssl connection failed'))
- sslsocket._hgcaloaded = caloaded
+ sslsocket._hgstate = {
+ 'caloaded': caloaded,
+ }
return sslsocket
def _verifycert(cert, hostname):
'''Verify that cert (in socket.getpeercert() format) matches hostname.
CRLs is not handled.
Returns error message if any problems are found and None on success.
@@ -336,17 +338,17 @@ class validator(object):
# the same as below for BC.
if self.ui.insecureconnections:
self.ui.warn(_('warning: %s certificate with fingerprint %s not '
'verified (check hostfingerprints or web.cacerts '
'config setting)\n') %
(host, nicefingerprint))
return
- if not sock._hgcaloaded:
+ if not sock._hgstate['caloaded']:
if strict:
raise error.Abort(_('%s certificate with fingerprint %s not '
'verified') % (host, nicefingerprint),
hint=_('check hostfingerprints or '
'web.cacerts config setting'))
else:
self.ui.warn(_('warning: %s certificate with fingerprint %s '
'not verified (check hostfingerprints or '
More information about the Mercurial-devel
mailing list