Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions cheroot/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,14 +697,22 @@ def test_https_over_http_error(http_server, ip_addr):
http.client.HTTPSConnection(
f'{interface}:{port}',
).request('GET', '/')
expected_substring = (
'record layer failure'
if IS_ABOVE_OPENSSL31
else 'wrong version number'
if IS_ABOVE_OPENSSL10
else 'unknown protocol'
)
assert expected_substring in ssl_err.value.args[-1]
actual_error = ssl_err.value.args[-1]
if IS_ABOVE_OPENSSL31:
# OpenSSL 3.1+ usually reports 'record layer failure', but some builds
# report 'wrong version number' instead (e.g. Python 3.14.6 on Windows
# where the TCP reset takes a different code path). See CPython:
# https://github.com/python/cpython/blob/\
# 1b9fe5c7226eccc8b269a7443148033080399f43\
# /Lib/test/test_ssl.py#L5705
assert (
'record layer failure' in actual_error
or 'wrong version number' in actual_error
), actual_error
elif IS_ABOVE_OPENSSL10:
assert 'wrong version number' in actual_error
else: # pragma: no cover
assert 'unknown protocol' in actual_error


def test_http_over_https_no_data(mocker):
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog-fragments.d/828.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed ``test_https_over_http_error`` failing on Windows with OpenSSL 3.1+,
where the SSL error message is ``wrong version number`` rather than
``record layer failure`` -- by :user:`julianz-`.
Loading