Skip to content

bpo-43921: Fix test_ssl.test_wrong_cert_tls13() on Windows #26502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3190,7 +3190,8 @@ def test_wrong_cert_tls13(self):
)
with server, \
client_context.wrap_socket(socket.socket(),
server_hostname=hostname) as s:
server_hostname=hostname,
suppress_ragged_eofs=False) as s:
# TLS 1.3 perform client cert exchange after handshake
s.connect((HOST, server.port))
try:
Expand All @@ -3207,13 +3208,7 @@ def test_wrong_cert_tls13(self):
if support.verbose:
sys.stdout.write("\nsocket.error is %r\n" % e)
else:
if sys.platform == "win32":
self.skipTest(
"Ignoring failed test_wrong_cert_tls13 test case. "
"The test is flaky on Windows, see bpo-43921."
)
else:
self.fail("Use of invalid cert should have failed!")
self.fail("Use of invalid cert should have failed!")

def test_rude_shutdown(self):
"""A brutal shutdown of an SSL server should raise an OSError
Expand Down Expand Up @@ -4450,7 +4445,8 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
server = ThreadedEchoServer(context=server_context, chatty=True)
with server:
with client_context.wrap_socket(socket.socket(),
server_hostname=hostname) as s:
server_hostname=hostname,
suppress_ragged_eofs=False) as s:
s.connect((HOST, server.port))
s.write(b'PHA')
# test sometimes fails with EOF error. Test passes as long as
Expand All @@ -4461,17 +4457,13 @@ def msg_cb(conn, direction, version, content_type, msg_type, data):
):
# receive CertificateRequest
data = s.recv(1024)
if not data:
raise ssl.SSLError(1, "EOF occurred")
self.assertEqual(data, b'OK\n')

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

# receive alert
data = s.recv(1024)
if not data:
raise ssl.SSLError(1, "EOF occurred")
s.recv(1024)

def test_pha_optional(self):
if support.verbose:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix test_ssl.test_wrong_cert_tls13(): use ``suppress_ragged_eofs=False``,
since ``read()`` can raise :exc:`ssl.SSLEOFError` on Windows. Patch by
Victor Stinner.