diff --git a/Lib/ssl.py b/Lib/ssl.py index 1d5873726441e4..b037416e2b3fb9 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -264,6 +264,14 @@ class _TLSMessageType: import errno import warnings +if not OPENSSL_VERSION_INFO[:2] == _OPENSSL_API_VERSION[:2]: + warnings.warn( + "Python was compiled against OpenSSL " + f"{_OPENSSL_API_VERSION[0]}.{_OPENSSL_API_VERSION[1]}, " + "but is using OpenSSL " + f"{OPENSSL_VERSION_INFO[0]}.{OPENSSL_VERSION_INFO[1]}. " + "OpenSSL does not guarantee compatibility between different major versions.", + category=RuntimeWarning, stacklevel=2) socket_error = OSError # keep that public name in module namespace diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-12-31-13-27-16.gh-issue-99951.BGyDJT.rst b/Misc/NEWS.d/next/Core and Builtins/2022-12-31-13-27-16.gh-issue-99951.BGyDJT.rst new file mode 100644 index 00000000000000..c2583e008ac411 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-12-31-13-27-16.gh-issue-99951.BGyDJT.rst @@ -0,0 +1 @@ +Raises :exc:`RuntimeWarning` when there is an OpenSSL major version mismatch between the version python was compiled against and the version python is currently using.