Skip to content

Commit 52f3fe6

Browse files
committed
handle openssl3 error in ssl tests
Using OpenSSL 3, the expected error string caught in ssl tests has changed. E AssertionError: assert 'wrong version number' in '[SSL] record layer failure (_ssl.c:1000)' This is already handled for OpenSSL pre-1.1 and gte-1.1, adding handling for OpenSSL 3+ Fixes: #645
1 parent 41584b8 commit 52f3fe6

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

cheroot/_compat.py

+2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
try:
99
import ssl
1010
IS_ABOVE_OPENSSL10 = ssl.OPENSSL_VERSION_INFO >= (1, 1)
11+
IS_ABOVE_OPENSSL31 = ssl.OPENSSL_VERSION_INFO >= (3, 2)
1112
del ssl
1213
except ImportError:
1314
IS_ABOVE_OPENSSL10 = None
15+
IS_OPENSSL3 = None
1416

1517

1618
IS_CI = bool(os.getenv('CI'))

cheroot/_compat.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from typing import Any, ContextManager, Optional, Type, Union
33
def suppress(*exceptions: Type[BaseException]) -> ContextManager[None]: ...
44

55
IS_ABOVE_OPENSSL10: Optional[bool]
6+
IS_ABOVE_OPENSSL31: Optional[bool]
67
IS_CI: bool
78
IS_GITHUB_ACTIONS_WORKFLOW: bool
89
IS_PYPY: bool

cheroot/test/test_ssl.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import trustme
1818

1919
from .._compat import bton, ntob, ntou
20-
from .._compat import IS_ABOVE_OPENSSL10, IS_CI, IS_PYPY
20+
from .._compat import IS_ABOVE_OPENSSL10, IS_ABOVE_OPENSSL31, IS_CI, IS_PYPY
2121
from .._compat import IS_LINUX, IS_MACOS, IS_WINDOWS
2222
from ..server import HTTPServer, get_ssl_adapter_class
2323
from ..testing import (
@@ -597,8 +597,9 @@ def test_https_over_http_error(http_server, ip_addr):
597597
),
598598
).request('GET', '/')
599599
expected_substring = (
600-
'wrong version number' if IS_ABOVE_OPENSSL10
601-
else 'unknown protocol'
600+
'record layer failure' if IS_ABOVE_OPENSSL31
601+
else 'wrong version number' if IS_ABOVE_OPENSSL10
602+
else 'unknown protocol'
602603
)
603604
assert expected_substring in ssl_err.value.args[-1]
604605

0 commit comments

Comments
 (0)