Skip to content

Commit 481ae08

Browse files
freakboy3742hugovk
authored andcommitted
[3.11] 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 b591c95 commit 481ae08

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
@@ -5041,15 +5041,27 @@ 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(
5045+
# Matches the following error messages:
5046+
# '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)'
5047+
# '[SSL: RECORD_LAYER_FAILURE] record layer failure (_ssl.c:1109)'
5048+
# '[SSL: HTTP_REQUEST] http request (_ssl.c:1143)'
5049+
r'wrong.version.number|record.layer.failure|http.request',
5050+
str(getattr(err, "reason", "")),
5051+
re.IGNORECASE,
5052+
)
5053+
):
50455054
# On Windows the TCP RST leads to a ConnectionResetError
50465055
# (ECONNRESET) which Linux doesn't appear to surface to userspace.
50475056
# 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.
5057+
# the actual wrapping... we get an SSLError from OpenSSL. This is
5058+
# typically WRONG_VERSION_NUMBER. The same happens on iOS, but
5059+
# RECORD_LAYER_FAILURE or HTTP_REQUEST is the error.
5060+
#
5061+
# While appropriate, these scenarios aren't what we're specifically
5062+
# trying to test. The way this test is written is known to work on
5063+
# Linux. We'll skip it anywhere else that it does not present as
5064+
# doing so.
50535065
try:
50545066
self.skipTest(f"Could not recreate conditions on {sys.platform}:"
50555067
f" {err=}")

0 commit comments

Comments
 (0)