summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-05-06 20:19:48 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-05-06 20:19:48 (GMT)
commitf16ff7bc214e9df514013ba9d6fd1ef86a9086ef (patch)
treee061d20e701255d53c72680eefaa26a7222b154d /Lib/ssl.py
parent31bc8bef63fdb92c6ea776e093243eb421247f22 (diff)
downloadcpython-f16ff7bc214e9df514013ba9d6fd1ef86a9086ef.zip
cpython-f16ff7bc214e9df514013ba9d6fd1ef86a9086ef.tar.gz
cpython-f16ff7bc214e9df514013ba9d6fd1ef86a9086ef.tar.bz2
Issue #17918: When using SSLSocket.accept(), if the SSL handshake failed on the new socket, the socket would linger indefinitely.
Thanks to Peter Saveliev for reporting.
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 8829635..329b9d1 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -344,17 +344,21 @@ class SSLSocket(socket):
SSL channel, and the address of the remote client."""
newsock, addr = socket.accept(self)
- return (SSLSocket(newsock,
- keyfile=self.keyfile,
- certfile=self.certfile,
- server_side=True,
- cert_reqs=self.cert_reqs,
- ssl_version=self.ssl_version,
- ca_certs=self.ca_certs,
- ciphers=self.ciphers,
- do_handshake_on_connect=self.do_handshake_on_connect,
- suppress_ragged_eofs=self.suppress_ragged_eofs),
- addr)
+ try:
+ return (SSLSocket(newsock,
+ keyfile=self.keyfile,
+ certfile=self.certfile,
+ server_side=True,
+ cert_reqs=self.cert_reqs,
+ ssl_version=self.ssl_version,
+ ca_certs=self.ca_certs,
+ ciphers=self.ciphers,
+ do_handshake_on_connect=self.do_handshake_on_connect,
+ suppress_ragged_eofs=self.suppress_ragged_eofs),
+ addr)
+ except socket_error as e:
+ newsock.close()
+ raise e
def makefile(self, mode='r', bufsize=-1):