[issue13721] ssl.wrap_socket on a connected but failed connection succeeds and .peer_certificate gives AttributeError

Ben Darnell report at bugs.python.org
Sun Apr 28 04:46:47 CEST 2013


Ben Darnell added the comment:

We found a related issue with Tornado: https://github.com/facebook/tornado/pull/750

We call wrap_socket with do_handshake_on_connect=False and then call do_handshake when the socket is ready.  If the getpeername call in wrap_socket fails with ENOTCONN because the connection was reset immediately after it was opened, then do_handshake will fail with an AttributeError (because self._sslobj is None).  do_handshake should fail with a clearer error (perhaps socket.error with ENOTCONN or ECONNABORTED?) if self._sslobj is None.

Also, Mac OS X appears to return EINVAL from getpeername in this case, instead of ENOTCONN.  wrap_socket should probably treat ENOTCONN and EINVAL from getpeername as equivalent.

----------
nosy: +Ben.Darnell

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13721>
_______________________________________


More information about the Python-bugs-list mailing list