diff options
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r-- | Lib/test/test_ssl.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 5b53b8250f..d48d6e5569 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2188,7 +2188,7 @@ class ThreadedEchoServer(threading.Thread): self.sock, server_side=True) self.server.selected_npn_protocols.append(self.sslconn.selected_npn_protocol()) self.server.selected_alpn_protocols.append(self.sslconn.selected_alpn_protocol()) - except (ConnectionResetError, BrokenPipeError) as e: + except (ConnectionResetError, BrokenPipeError, ConnectionAbortedError) as e: # We treat ConnectionResetError as though it were an # SSLError - OpenSSL on Ubuntu abruptly closes the # connection when asked to use an unsupported protocol. @@ -2196,6 +2196,9 @@ class ThreadedEchoServer(threading.Thread): # BrokenPipeError is raised in TLS 1.3 mode, when OpenSSL # tries to send session tickets after handshake. # https://github.com/openssl/openssl/issues/6342 + # + # ConnectionAbortedError is raised in TLS 1.3 mode, when OpenSSL + # tries to send session tickets after handshake when using WinSock. self.server.conn_errors.append(str(e)) if self.server.chatty: handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n") @@ -2326,7 +2329,7 @@ class ThreadedEchoServer(threading.Thread): sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n" % (msg, ctype, msg.lower(), ctype)) self.write(msg.lower()) - except ConnectionResetError: + except (ConnectionResetError, ConnectionAbortedError): # XXX: OpenSSL 1.1.1 sometimes raises ConnectionResetError # when connection is not shut down gracefully. if self.server.chatty and support.verbose: @@ -2336,6 +2339,18 @@ class ThreadedEchoServer(threading.Thread): ) self.close() self.running = False + except ssl.SSLError as err: + # On Windows sometimes test_pha_required_nocert receives the + # PEER_DID_NOT_RETURN_A_CERTIFICATE exception + # before the 'tlsv13 alert certificate required' exception. + # If the server is stopped when PEER_DID_NOT_RETURN_A_CERTIFICATE + # is received test_pha_required_nocert fails with ConnectionResetError + # because the underlying socket is closed + if 'PEER_DID_NOT_RETURN_A_CERTIFICATE' == err.reason: + if self.server.chatty and support.verbose: + sys.stdout.write(err.args[1]) + # test_pha_required_nocert is expecting this exception + raise ssl.SSLError('tlsv13 alert certificate required') except OSError: if self.server.chatty: handle_error("Test server failure:\n") |