8000 bpo-43921: Fix test_ssl.test_wrong_cert_tls13() on Windows (GH-26502)… · python/cpython@d2ab15f · GitHub
[go: up one dir, main page]

Skip to content

Commit d2ab15f

Browse files
bpo-43921: Fix test_ssl.test_wrong_cert_tls13() on Windows (GH-26502) (GH-26518)
Fix test_ssl.test_wrong_cert_tls13(): use suppress_ragged_eofs=False, since read() can raise ssl.SSLEOFError on Windows. (cherry picked from commit ea0210f) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent cea0585 commit d2ab15f

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
@@ -3194,7 +3194,8 @@ def test_wrong_cert_tls13(self):
31943194
)
31953195
with server, \
31963196
client_context.wrap_socket(socket.socket(),
3197-
server_hostname=hostname) as s:
3197+
server_hostname=hostname,
3198+
suppress_ragged_eofs=False) as s:
31983199
# TLS 1.3 perform client cert exchange after handshake
31993200
s.connect((HOST, server.port))
32003201
try:
@@ -3211,13 +3212,7 @@ def test_wrong_cert_tls13(self):
32113212
if support.verbose:
32123213
sys.stdout.write("\nsocket.error is %r\n" % e)
32133214
else:
3214-
if sys.platform == "win32":
3215-
self.skipTest(
3216-
"Ignoring failed test_wrong_cert_tls13 test case. "
3217-
"The test is flaky on Windows, see bpo-43921."
3218-
)
3219-
else:
3220-
self.fail("Use of invalid cert should have failed!")
3215+
self.fail("Use of invalid cert should have failed!")
32213216

32223217
def test_rude_shutdown(self):
32233218
"""A brutal shutdown of an SSL server should raise an OSError
@@ -4454,7 +4449,8 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
44544449
server = ThreadedEchoServer(context=server_context, chatty=True)
44554450
with server:
44564451
with client_context.wrap_socket(socket.socket(),
4457-
server_hostname=hostname) as s:
4452+
server_hostname=hostname,
4453+
suppress_ragged_eofs=False) as s:
44584454
s.connect((HOST, server.port))
44594455
s.write(b'PHA')
44604456
# test sometimes fails with EOF error. Test passes as long as
@@ -4465,17 +4461,13 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
44654461
):
44664462
# receive CertificateRequest
44674463
data = s.recv(1024)
4468-
if not data:
4469-
raise ssl.SSLError(1, "EOF occurred")
44704464
self.assertEqual(data, b'OK\n')
44714465

44724466
# send empty Certificate + Finish
44734467
s.write(b'HASCERT')
44744468

44754469
# receive alert
4476-
data = s.recv(1024)
4477-
if not data:
4478-
raise ssl.SSLError(1, "EOF occurred")
4470+
s.recv(1024)
44794471

44804472
def test_pha_optional(self):
44814473
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)
0