[issue9211] Cannot close socket after ssl handshake failed
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?
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
sslsock = ssl.wrap_socket(newsock, server_side=True, certfile="../cert.pem", keyfile="../cert.pem")
print "ssl handshake failed"
newsock.send("bye\r\n") # succeeds
newsock.close() # doesn't work
title: Cannot close socket after ssl handshake failed
versions: Python 2.5, Python 2.6
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list