Skip to content

Commit f5b8f7a

Browse files
hugovkfreakboy3742
andauthored
[3.12] gh-148508: Add another common pattern for iOS SSL failures to test_ssl (GH-150442) (#158246)
Match also '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'. (cherry picked from commit 540b3d0) Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
1 parent 308b715 commit f5b8f7a

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎Lib/test/test_ssl.py‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4944,15 +4944,27 @@ def non_linux_skip_if_other_okay_error(self, err):
49444944
return # Expect the full test setup to always work on Linux.
49454945
if (isinstance(err, ConnectionResetError) or
49464946
(isinstance(err, OSError) and err.errno == errno.EINVAL) or
4947-
re.search('wrong.version.number', str(getattr(err, "reason", "")), re.I)):
4947+
re.search(
4948+
# Matches the following error messages:
4949+
# '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)'
4950+
# '[SSL: RECORD_LAYER_FAILURE] record layer failure (_ssl.c:1109)'
4951+
# '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'
4952+
r'wrong.version.number|record.layer.failure|http.request',
4953+
str(getattr(err, "reason", "")),
4954+
re.IGNORECASE,
4955+
)
4956+
):
49484957
# On Windows the TCP RST leads to a ConnectionResetError
49494958
# (ECONNRESET) which Linux doesn't appear to surface to userspace.
49504959
# If wrap_socket() winds up on the "if connected:" path and doing
4951-
# the actual wrapping... we get an SSLError from OpenSSL. Typically
4952-
# WRONG_VERSION_NUMBER. While appropriate, neither is the scenario
4953-
# we're specifically trying to test. The way this test is written
4954-
# is known to work on Linux. We'll skip it anywhere else that it
4955-
# does not present as doing so.
4960+
# the actual wrapping... we get an SSLError from OpenSSL. This is
4961+
# typically WRONG_VERSION_NUMBER. The same happens on iOS, but
4962+
# RECORD_LAYER_FAILURE or HTTP_REQUEST is the error.
4963+
#
4964+
# While appropriate, these scenarios aren't what we're specifically
4965+
# trying to test. The way this test is written is known to work on
4966+
# Linux. We'll skip it anywhere else that it does not present as
4967+
# doing so.
49564968
try:
49574969
self.skipTest(f"Could not recreate conditions on {sys.platform}:"
49584970
f" {err=}")

0 commit comments

Comments
 (0)