Skip to content

Commit 819bead

Browse files
[3.11] pythongh-148508: Add resilience to SSL preauth tests on iOS (pythonGH-148536) (python#148540)
Adds handling for a test case seen in the iOS SSL tests where an SSL connection fails to handshake correctly. (cherry picked from commit c40e8b0) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
1 parent f06b1cc commit 819bead

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎Lib/test/test_ssl.py‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5041,15 +5041,20 @@ def non_linux_skip_if_other_okay_error(self, err):
50415041
return # Expect the full test setup to always work on Linux.
50425042
if (isinstance(err, ConnectionResetError) or
50435043
(isinstance(err, OSError) and err.errno == errno.EINVAL) or
5044-
re.search('wrong.version.number', getattr(err, "reason", ""), re.I)):
5044+
re.search('wrong.version.number', str(getattr(err, "reason", "")), re.I) or
5045+
re.search('record.layer.failure', str(getattr(err, "reason", "")), re.I)
5046+
):
50455047
# On Windows the TCP RST leads to a ConnectionResetError
50465048
# (ECONNRESET) which Linux doesn't appear to surface to userspace.
50475049
# If wrap_socket() winds up on the "if connected:" path and doing
5048-
# the actual wrapping... we get an SSLError from OpenSSL. Typically
5049-
# WRONG_VERSION_NUMBER. While appropriate, neither is the scenario
5050-
# we're specifically trying to test. The way this test is written
5051-
# is known to work on Linux. We'll skip it anywhere else that it
5052-
# does not present as doing so.
5050+
# the actual wrapping... we get an SSLError from OpenSSL. This is
5051+
# typically WRONG_VERSION_NUMBER. The same happens on iOS, but
5052+
# RECORD_LAYER_FAILURE is the error.
5053+
#
5054+
# While appropriate, neither is the scenario we're specifically
5055+
# trying to test. The way this test is written is known to work on
5056+
# Linux. We'll skip it anywhere else that it does not present as
5057+
# doing so.
50535058
try:
50545059
self.skipTest(f"Could not recreate conditions on {sys.platform}:"
50555060
f" {err=}")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
An intermittent timing error when running SSL tests on iOS has been
2+
resolved.

0 commit comments

Comments
 (0)