sslutil: abort properly if no certificate received for https connection
According to the documentation SSLSocket.getpeercert() can return None.
--- a/mercurial/sslutil.py Mon Jan 09 14:43:25 2012 +0100
+++ b/mercurial/sslutil.py Mon Jan 09 14:56:05 2012 +0100
@@ -113,6 +113,9 @@
if not sock.cipher(): # work around http://bugs.python.org/issue13721
raise util.Abort(_('%s ssl connection error') % host)
peercert = sock.getpeercert(True)
+ if not peercert:
+ raise util.Abort(_('%s certificate error: '
+ 'no certificate received') % host)
peerfingerprint = util.sha1(peercert).hexdigest()
nicefingerprint = ":".join([peerfingerprint[x:x + 2]
for x in xrange(0, len(peerfingerprint), 2)])