[issue9211] Cannot close socket after ssl handshake failed
Christian Hager
report at bugs.python.org
Fri Jul 9 11:21:34 CEST 2010
New submission from Christian Hager <metakaram at gmail.com>:
When running a SSL socket server in Python 2.5 or 2.6 (didn't try with newer versions), new connections are setup with "ssl.wrap_socket()". Everything works fine if I connect a client with SSL, but if I just telnet to the server it's not possible to close the socket anymore (receiving data works fine through the non-ssl socket though).
I get a SSL exception like this: "SSLError: [Errno 1] _ssl.c:480: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol". After that I am not able to close the socket, but still can send data on the non-ssl-wrapped socket. How would I close this now open non-ssl socket?
Simplified code:
read_sockets,write_sockets,error_sockets = select.select(CONNECTION_LIST,[],[])
for sock in read_sockets:
if sock == server_socket:
newsock, addr = server_socket.accept()
# SSL Setup
try:
sslsock = ssl.wrap_socket(newsock, server_side=True, certfile="../cert.pem", keyfile="../cert.pem")
CONNECTION_LIST.append(sslsock)
except:
print "ssl handshake failed"
try:
newsock.send("bye\r\n") # succeeds
newsock.close() # doesn't work
----------
components: IO
messages: 109697
nosy: metachris
priority: normal
severity: normal
status: open
title: Cannot close socket after ssl handshake failed
versions: Python 2.5, Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9211>
_______________________________________
More information about the Python-bugs-list
mailing list