Skip to content

Commit 4c403b8

Browse files
bpo-37322: ssl test_pha_required_nocert() ignores expected SSLError (GH-14670)
test_ssl.test_pha_required_nocert() now uses support.catch_threading_exception() to ignore the expected SSLError in ConnectionHandler of ThreadedEchoServer (it is only raised sometimes on Windows). (cherry picked from commit 73ea546) Co-authored-by: Victor Stinner <[email protected]>
1 parent bbad695 commit 4c403b8

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

Lib/test/test_ssl.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4320,21 +4320,24 @@ def test_pha_required_nocert(self):
43204320
server_context.verify_mode = ssl.CERT_REQUIRED
43214321
client_context.post_handshake_auth = True
43224322

4323-
server = ThreadedEchoServer(context=server_context, chatty=False)
4324-
with server:
4325-
with client_context.wrap_socket(socket.socket(),
4326-
server_hostname=hostname) as s:
4327-
s.connect((HOST, server.port))
4328-
s.write(b'PHA')
4329-
# receive CertificateRequest
4330-
self.assertEqual(s.recv(1024), b'OK\n')
4331-
# send empty Certificate + Finish
4332-
s.write(b'HASCERT')
4333-
# receive alert
4334-
with self.assertRaisesRegex(
4335-
ssl.SSLError,
4336-
'tlsv13 alert certificate required'):
4337-
s.recv(1024)
4323+
# Ignore expected SSLError in ConnectionHandler of ThreadedEchoServer
4324+
# (it is only raised sometimes on Windows)
4325+
with support.catch_threading_exception() as cm:
4326+
server = ThreadedEchoServer(context=server_context, chatty=False)
4327+
with server:
4328+
with client_context.wrap_socket(socket.socket(),
4329+
server_hostname=hostname) as s:
4330+
s.connect((HOST, server.port))
4331+
s.write(b'PHA')
4332+
# receive CertificateRequest
4333+
self.assertEqual(s.recv(1024), b'OK\n')
4334+
# send empty Certificate + Finish
4335+
s.write(b'HASCERT')
4336+
# receive alert
4337+
with self.assertRaisesRegex(
4338+
ssl.SSLError,
4339+
'tlsv13 alert certificate required'):
4340+
s.recv(1024)
43384341

43394342
def test_pha_optional(self):
43404343
if support.verbose:

0 commit comments

Comments
 (0)