Skip to content

Commit 655d2db

Browse files
freakboy3742hugovk
authored andcommitted
[3.12] gh-148508: Add another common pattern for iOS SSL failures to test_ssl (GH-150442)
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 da0b9b9 commit 655d2db

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
@@ -4864,15 +4864,27 @@ def non_linux_skip_if_other_okay_error(self, err):
48644864
return # Expect the full test setup to always work on Linux.
48654865
if (isinstance(err, ConnectionResetError) or
48664866
(isinstance(err, OSError) and err.errno == errno.EINVAL) or
4867-
re.search('wrong.version.number', str(getattr(err, "reason", "")), re.I)):
4867+
re.search(
4868+
# Matches the following error messages:
4869+
# '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)'
4870+
# '[SSL: RECORD_LAYER_FAILURE] record layer failure (_ssl.c:1109)'
4871+
# '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'
4872+
r'wrong.version.number|record.layer.failure|http.request',
4873+
str(getattr(err, "reason", "")),
4874+
re.IGNORECASE,
4875+
)
4876+
):
48684877
# On Windows the TCP RST leads to a ConnectionResetError
48694878
# (ECONNRESET) which Linux doesn't appear to surface to userspace.
48704879
# If wrap_socket() winds up on the "if connected:" path and doing
4871-
# the actual wrapping... we get an SSLError from OpenSSL. Typically
4872-
# WRONG_VERSION_NUMBER. While appropriate, neither is the scenario
4873-
# we're specifically trying to test. The way this test is written
4874-
# is known to work on Linux. We'll skip it anywhere else that it
4875-
# does not present as doing so.
4880+
# the actual wrapping... we get an SSLError from OpenSSL. This is
4881+
# typically WRONG_VERSION_NUMBER. The same happens on iOS, but
4882+
# RECORD_LAYER_FAILURE or HTTP_REQUEST is the error.
4883+
#
4884+
# While appropriate, these scenarios aren't what we're specifically
4885+
# trying to test. The way this test is written is known to work on
4886+
# Linux. We'll skip it anywhere else that it does not present as
4887+
# doing so.
48764888
try:
48774889
self.skipTest(f"Could not recreate conditions on {sys.platform}:"
48784890
f" {err=}")

0 commit comments

Comments
 (0)