Skip to content

Commit ea0210f

Browse files
authored
bpo-43921: Fix test_ssl.test_wrong_cert_tls13() on Windows (GH-26502)
Fix test_ssl.test_wrong_cert_tls13(): use suppress_ragged_eofs=False, since read() can raise ssl.SSLEOFError on Windows.
1 parent 82ad22a commit ea0210f

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

Lib/test/test_ssl.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,7 +3190,8 @@ def test_wrong_cert_tls13(self):
31903190
)
31913191
with server, \
31923192
client_context.wrap_socket(socket.socket(),
3193-
server_hostname=hostname) as s:
3193+
server_hostname=hostname,
3194+
suppress_ragged_eofs=False) as s:
31943195
# TLS 1.3 perform client cert exchange after handshake
31953196
s.connect((HOST, server.port))
31963197
try:
@@ -3207,13 +3208,7 @@ def test_wrong_cert_tls13(self):
32073208
if support.verbose:
32083209
sys.stdout.write("\nsocket.error is %r\n" % e)
32093210
else:
3210-
if sys.platform == "win32":
3211-
self.skipTest(
3212-
"Ignoring failed test_wrong_cert_tls13 test case. "
3213-
"The test is flaky on Windows, see bpo-43921."
3214-
)
3215-
else:
3216-
self.fail("Use of invalid cert should have failed!")
3211+
self.fail("Use of invalid cert should have failed!")
32173212

32183213
def test_rude_shutdown(self):
32193214
"""A brutal shutdown of an SSL server should raise an OSError
@@ -4450,7 +4445,8 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
44504445
server = ThreadedEchoServer(context=server_context, chatty=True)
44514446
with server:
44524447
with client_context.wrap_socket(socket.socket(),
4453-
server_hostname=hostname) as s:
4448+
server_hostname=hostname,
4449+
suppress_ragged_eofs=False) as s:
44544450
s.connect((HOST, server.port))
44554451
s.write(b'PHA')
44564452
# test sometimes fails with EOF error. Test passes as long as
@@ -4461,17 +4457,13 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
44614457
):
44624458
# receive CertificateRequest
44634459
data = s.recv(1024)
4464-
if not data:
4465-
raise ssl.SSLError(1, "EOF occurred")
44664460
self.assertEqual(data, b'OK\n')
44674461

44684462
# send empty Certificate + Finish
44694463
s.write(b'HASCERT')
44704464

44714465
# receive alert
4472-
data = s.recv(1024)
4473-
if not data:
4474-
raise ssl.SSLError(1, "EOF occurred")
4466+
s.recv(1024)
44754467

44764468
def test_pha_optional(self):
44774469
if support.verbose:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix test_ssl.test_wrong_cert_tls13(): use ``suppress_ragged_eofs=False``,
2+
since ``read()`` can raise :exc:`ssl.SSLEOFError` on Windows. Patch by
3+
Victor Stinner.

0 commit comments

Comments
 (0)