Get an error <'NoneType' object has no attribute 'peer_certificate'> when clone code from google code by Mercurial

Mads Kiilerich mads at kiilerich.com
Fri Aug 12 18:46:07 UTC 2011


On 08/12/2011 07:10 PM, Sailing Cai wrote:
> *Description*
>
> There is no error when clone by http, the error only meet when clone by
> https.
>
> *Env*
>
> Install Mercurial by mercurial-1.9.1+20110801-py2.6-macosx10.6.mpkg from
> http://mercurial.berkwood.com/binaries/Mercurial-1.9.1-py2.6-macosx10.6.zip
>
> site-packages location: /Library/Python/2.6/site-packages
>
> *Command:*
>
> hg clone https://code.google.com/p/cooliris-toolkit/
>
> *Error Info*
>
>      hg clonehttps://code.google.com/p/cooliris-toolkit/
>      ** unknown exception encountered, please report by visiting
>      **http://mercurial.selenic.com/wiki/BugTracker
>      ** Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)]
>      ** Mercurial Distributed SCM (version 1.9.1+20110801)
>      ** Extensions loaded:
>      Traceback (most recent call last):
>        File"/usr/local/bin/hg", line 38, in
>          mercurial.dispatch.run()
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 27, in run
>          sys.exit(dispatch(request(sys.argv[1:])))
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 64, in dispatch
>          return _runcatch(req)
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 87, in _runcatch
>          return _dispatch(req)
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 679, in _dispatch
>          cmdpats, cmdoptions)
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 454, in runcommand
>          ret = _runcommand(ui, options, cmd, d)
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 733, in _runcommand
>          return checkargs()
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 687, in checkargs
>          return cmdfunc()
>        File"/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 676, in
>          d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
>        File"/Library/Python/2.6/site-packages/mercurial/util.py", line 385, in check
>          return func(*args, **kwargs)
>        File"/Library/Python/2.6/site-packages/mercurial/commands.py", line 1041, in clone
>          branch=opts.get('branch'))
>        File"/Library/Python/2.6/site-packages/mercurial/hg.py", line 217, in clone
>          srcrepo = repository(remoteui(ui, peeropts), source)
>        File"/Library/Python/2.6/site-packages/mercurial/hg.py", line 93, in repository
>          repo = _peerlookup(path).instance(ui, path, create)
>        File"/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 231, in instance
>          inst._fetchcaps()
>        File"/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 56, in _fetchcaps
>          self.caps = set(self._call('capabilities').split())
>        File"/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 164, in _call
>          fp = self._callstream(cmd, **args)
>        File"/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 114, in _callstream
>          resp = self.urlopener.open(req)
>        File"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 383, in open
>          response = self._open(req, data)
>        File"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 401, in _open
>          '_open', req)
>        File"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain
>          result = func(*args)
>        File"/Library/Python/2.6/site-packages/mercurial/url.py", line 352, in https_open
>          return self.do_open(self._makeconnection, req)
>        File"/Library/Python/2.6/site-packages/mercurial/keepalive.py", line 256, in do_open
>          self._start_transaction(h, req)
>        File"/Library/Python/2.6/site-packages/mercurial/url.py", line 342, in _start_transaction
>          return keepalive.KeepAliveHandler._start_transaction(self, h, req)
>        File"/Library/Python/2.6/site-packages/mercurial/keepalive.py", line 354, in _start_transaction
>          h.endheaders()
>        File"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 868, in endheaders
>          self._send_output()
>        File"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 740, in _send_output
>          self.send(msg)
>        File"/Library/Python/2.6/site-packages/mercurial/url.py", line 129, in _sendfile
>          orgsend(self, data)
>        File"/Library/Python/2.6/site-packages/mercurial/keepalive.py", line 537, in safesend
>          self.connect()
>        File"/Library/Python/2.6/site-packages/mercurial/url.py", line 331, in connect
>          sslutil.validator(self.ui, host)(self.sock)
>        File"/Library/Python/2.6/site-packages/mercurial/sslutil.py", line 97, in __call__
>          msg = _verifycert(sock.getpeercert(), host)
>        File"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ssl.py", line 157, in getpeercert
>          return self._sslobj.peer_certificate(binary_form)
>      AttributeError:'NoneType'  object has no attribute'peer_certificate'
>
> *Question*
>
> How can I resolve the error ? Is there any conflict in python libraries ?

It seems like something closes the tcp connection before Mercurial gets 
to verify the remote certificate. In that situation Pythons ssl module 
behaves in a way that Mercurial could handle more elegant and abort with 
something like: 'error getting remote certificate'.

The problem is probably some kind of firewall - perhaps the Great 
Firewall of China?

You could try to experiment with other kinds of https traffic from other 
applications, cloning from other servers or using another computer or 
another network connection. You could also try to analyze network 
traffic and use that to point fingers at someone.

/Mads



More information about the Mercurial mailing list