This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mcjeff
Recipients mcjeff
Date 2012-10-29.15:53:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351526039.51.0.105215109749.issue16357@psf.upfronthosting.co.za>
In-reply-to
Content
mcjeff@martian:~/cpython$ ./python -V
Python 3.4.0a0

When an SSLSocket is created via SSLContext.wrap_socket, it is passed a _context parameter directly.  SSLSocket.__init__ sets self.context at this point, but it does not set self.keyfile or self.certfile.

However, in SSLSocket.accept, both keyfile & certfile are passed when creating a new, wrapped SSLSocket, from socket.accept's newsock.

The result is an attribute error.
>>> import ssl
>>> c = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
>>> c.load_cert_chain('Lib/test/keycert.pem')        
>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
>>> s.bind(('127.0.0.1', 5050))
>>> s.listen(5)
>>> s.accept()  # nc localhost 5050 in another term.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/google/home/mcjeff/cpython/Lib/ssl.py", line 557, in accept
    keyfile=self.keyfile, certfile=self.certfile,
AttributeError: 'SSLSocket' object has no attribute 'keyfile'
>>> 

Attached one-liner addresses it by passing in the context rather than the keyfile & certfile.

>>> s.accept()
(<socket.socket object, fd=4, family=2, type=1, proto=0>, ('127.0.0.1', 37306))
>>>
History
Date User Action Args
2012-10-29 15:53:59mcjeffsetrecipients: + mcjeff
2012-10-29 15:53:59mcjeffsetmessageid: <1351526039.51.0.105215109749.issue16357@psf.upfronthosting.co.za>
2012-10-29 15:53:59mcjefflinkissue16357 messages
2012-10-29 15:53:59mcjeffcreate