Skip to content

Commit 5c2191d

Browse files
authored
bpo-43921: Cleanup test_ssl.test_wrong_cert_tls13() (GH-26520)
Don't catch OSError, and check the SSLError message.
1 parent f349124 commit 5c2191d

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Lib/test/test_ssl.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,23 +3192,16 @@ def test_wrong_cert_tls13(self):
31923192
client_context.wrap_socket(socket.socket(),
31933193
server_hostname=hostname,
31943194
suppress_ragged_eofs=False) as s:
3195-
# TLS 1.3 perform client cert exchange after handshake
31963195
s.connect((HOST, server.port))
3197-
try:
3196+
with self.assertRaisesRegex(
3197+
ssl.SSLError,
3198+
'alert unknown ca|EOF occurred'
3199+
):
3200+
# TLS 1.3 perform client cert exchange after handshake
31983201
s.write(b'data')
31993202
s.read(1000)
32003203
s.write(b'should have failed already')
32013204
s.read(1000)
3202-
except ssl.SSLError as e:
3203-
if support.verbose:
3204-
sys.stdout.write("\nSSLError is %r\n" % e)
3205-
except OSError as e:
3206-
if e.errno != errno.ECONNRESET:
3207-
raise
3208-
if support.verbose:
3209-
sys.stdout.write("\nsocket.error is %r\n" % e)
3210-
else:
3211-
self.fail("Use of invalid cert should have failed!")
32123205

32133206
def test_rude_shutdown(self):
32143207
"""A brutal shutdown of an SSL server should raise an OSError

0 commit comments

Comments
 (0)