Skip to content

Commit 86966fd

Browse files
hugovkfreakboy3742
andauthored
[3.11] gh-148508: Add another common pattern for iOS SSL failures to test_ssl (GH-150442) (#158247)
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 889c92b commit 86966fd

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
@@ -5121,15 +5121,27 @@ def non_linux_skip_if_other_okay_error(self, err):
51215121
return # Expect the full test setup to always work on Linux.
51225122
if (isinstance(err, ConnectionResetError) or
51235123
(isinstance(err, OSError) and err.errno == errno.EINVAL) or
5124-
re.search('wrong.version.number', getattr(err, "reason", ""), re.I)):
5124+
re.search(
5125+
# Matches the following error messages:
5126+
# '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)'
5127+
# '[SSL: RECORD_LAYER_FAILURE] record layer failure (_ssl.c:1109)'
5128+
# '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'
5129+
r'wrong.version.number|record.layer.failure|http.request',
5130+
str(getattr(err, "reason", "")),
5131+
re.IGNORECASE,
5132+
)
5133+
):
51255134
# On Windows the TCP RST leads to a ConnectionResetError
51265135
# (ECONNRESET) which Linux doesn't appear to surface to userspace.
51275136
# If wrap_socket() winds up on the "if connected:" path and doing
5128-
# the actual wrapping... we get an SSLError from OpenSSL. Typically
5129-
# WRONG_VERSION_NUMBER. While appropriate, neither is the scenario
5130-
# we're specifically trying to test. The way this test is written
5131-
# is known to work on Linux. We'll skip it anywhere else that it
5132-
# does not present as doing so.
5137+
# the actual wrapping... we get an SSLError from OpenSSL. This is
5138+
# typically WRONG_VERSION_NUMBER. The same happens on iOS, but
5139+
# RECORD_LAYER_FAILURE or HTTP_REQUEST is the error.
5140+
#
5141+
# While appropriate, these scenarios aren't what we're specifically
5142+
# trying to test. The way this test is written is known to work on
5143+
# Linux. We'll skip it anywhere else that it does not present as
5144+
# doing so.
51335145
try:
51345146
self.skipTest(f"Could not recreate conditions on {sys.platform}:"
51355147
f" {err=}")

0 commit comments

Comments
 (0)