New submission from Jeff McNeil:

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))
>>>

----------
components: Library (Lib)
files: ssl_context.patch
keywords: patch
messages: 174121
nosy: mcjeff
priority: normal
severity: normal
status: open
title: SSLSocket created from SSLContext.wrap_socket doesn't include 
cert/keyfile
versions: Python 3.4
Added file: http://bugs.python.org/file27776/ssl_context.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16357>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to