Skip to content

gh-146207: Add support for OpenSSL 4.0.0 alpha1 - #146217

Merged
vstinner merged 12 commits into
python:mainfrom
vstinner:openssl4
Mar 25, 2026
Merged

gh-146207: Add support for OpenSSL 4.0.0 alpha1#146217
vstinner merged 12 commits into
python:mainfrom
vstinner:openssl4

Conversation

@vstinner

@vstinnervstinner commented Mar 20, 2026

Copy link
Copy Markdown
Member

OpenSSL 4.0.0 alpha1 no longer defines the symbols:

  • SSLv3_method
  • TLSv1_method
  • TLSv1_1_method
  • TLSv1_2_method

OpenSSL 4.0.0 alpha1 no longer defines the symbols:
* SSLv3_method
* TLSv1_method
* TLSv1_1_method
* TLSv1_2_method
@vstinner

Copy link
Copy Markdown
MemberAuthor

I didn't test my own change on OpenSSL 4.0.0 alpha1, I only asked @heitbaum to test my change.

@zware

Copy link
Copy Markdown
Member

@vstinner This patch (should, probably :) ) be enough to get you a test in CI, even if we don't want to merge it yet:

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2fa2ab768dc..40feaef01ce 100644
--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -275,6 +275,7 @@ jobs:
- { name: openssl, version: 3.4.4 }
- { name: openssl, version: 3.5.5 }
- { name: openssl, version: 3.6.1 }
+ - { name: openssl, version: 4.0.0-alpha1 }
## AWS-LC
- { name: aws-lc, version: 1.68.0 }
env:

@vstinner

Copy link
Copy Markdown
MemberAuthor

I applied @zware's patch: Tests / Ubuntu SSL tests (ubuntu-24.04, openssl, 4.0.0-alpha1) job is currently running.

@vstinner This patch (should, probably :) ) be enough to get you a test in CI, even if we don't want to merge it yet

Yeah, I will revert this patch once we get the openssl, 4.0.0-alpha1 CI job result.

@zware

Copy link
Copy Markdown
Member

Not as simple as hoped :(. I can reproduce the CI failure locally, though; there's a missing symlink (or openssl is just looking in the wrong place) for lib -> lib64 in the openssl install directory.

With that, I get these failures:

2 tests failed: test_ssl test_urllib2_localnet
43 tests OK.
0:00:23 load avg: 3.07 Re-running 2 failed tests in verbose mode in subprocesses
0:00:23 load avg: 3.07 Run 2 tests in parallel using 2 worker processes
0:00:24 load avg: 3.07 [1/2/1] test_ssl failed (1 failure)
Re-running test_ssl in verbose mode (matching: test_openssl_version)
test_ssl: testing with 'OpenSSL 4.0.0-alpha1 10 Mar 2026' (4, 0, 0, 0, 0)
under 'Linux-6.19.7-200.fc43.x86_64-x86_64-with-glibc2.42'HAS_SNI=TrueOP_ALL=0x80000050OP_NO_TLSv1_1=0x10000000
test_openssl_version (test.test_ssl.BasicSocketTests.test_openssl_version) ... FAIL
======================================================================
FAIL: test_openssl_version (test.test_ssl.BasicSocketTests.test_openssl_version)
----------------------------------------------------------------------
Traceback (most recent call last): File "/path/to/cpython/bump_multissl_awslc/Lib/test/test_ssl.py", line 590, in test_openssl_versionself.assertLess(n, 0x40000000) ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^AssertionError: 1073741824 not less than 1073741824 
---------------------------------------------------------------------- Ran 1 test in 0.007s FAILED (failures=1) test test_ssl failed
0:00:24 load avg: 3.07 [2/2/2] test_urllib2_localnet failed (2 errors) Re-running test_urllib2_localnet in verbose mode (matching: test_https, test_https_sni)
test_https (test.test_urllib2_localnet.TestUrlopen.test_https) ... ERROR
stopping HTTPS server joining HTTPS thread test_https_sni (test.test_urllib2_localnet.TestUrlopen.test_https_sni) ... ERROR
stopping HTTPS server joining HTTPS thread ======================================================================
ERROR: test_https (test.test_urllib2_localnet.TestUrlopen.test_https)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/path/to/cpython/bump_multissl_awslc/Lib/test/test_urllib2_localnet.py", line 569, in test_https
data =self.urlopen("https://localhost:%s/bizarre"% handler.port, context=context)
File "/path/to/cpython/bump_multissl_awslc/Lib/test/test_urllib2_localnet.py", line 473, in urlopen
l.extend(f.readlines(200))
~~~~~~~~~~~^^^^^
File "/path/to/cpython/bump_multissl_awslc/Lib/http/client.py", line 714, in readline
result =self.fp.readline(limit)
File "/path/to/cpython/bump_multissl_awslc/Lib/socket.py", line 734, in readintoreturnself._sock.recv_into(b)
~~~~~~~~~~~~~~~~~~~~^^^
File "/path/to/cpython/bump_multissl_awslc/Lib/ssl.py", line 1355, in recv_intoreturnself.read(nbytes, buffer)
~~~~~~~~~^^^^^^^^^^^^^^^^
File "/path/to/cpython/bump_multissl_awslc/Lib/ssl.py", line 1154, in readreturnself._sslobj.read(len, buffer)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ssl.SSLError: A failure in the SSL library occurred (_ssl.c:2977)
======================================================================
ERROR: test_https_sni (test.test_urllib2_localnet.TestUrlopen.test_https_sni)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/path/to/cpython/bump_multissl_awslc/Lib/test/test_urllib2_localnet.py", line 585, in test_https_sniself.urlopen("https://localhost:%s"% handler.port, context=context)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/cpython/bump_multissl_awslc/Lib/test/test_urllib2_localnet.py", line 473, in urlopen
l.extend(f.readlines(200))
~~~~~~~~~~~^^^^^
File "/path/to/cpython/bump_multissl_awslc/Lib/http/client.py", line 714, in readline
result =self.fp.readline(limit)
File "/path/to/cpython/bump_multissl_awslc/Lib/socket.py", line 734, in readintoreturnself._sock.recv_into(b)
~~~~~~~~~~~~~~~~~~~~^^^
File "/path/to/cpython/bump_multissl_awslc/Lib/ssl.py", line 1355, in recv_intoreturnself.read(nbytes, buffer)
~~~~~~~~~^^^^^^^^^^^^^^^^
File "/path/to/cpython/bump_multissl_awslc/Lib/ssl.py", line 1154, in readreturnself._sslobj.read(len, buffer)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ssl.SSLError: A failure in the SSL library occurred (_ssl.c:2977)
----------------------------------------------------------------------
Ran 2 tests in 0.122s
FAILED (errors=2)
test test_urllib2_localnet failed
2 tests failed again:
test_ssl test_urllib2_localnet

@vstinner
vstinner marked this pull request as draft March 20, 2026 16:42
@vstinner

Copy link
Copy Markdown
MemberAuthor

I tested multissltests.py using:

python3 Tools/ssl/multissltests.py --steps=library --base-directory "$PWD/multissl" --openssl '4.0.0-alpha1' --system Linux
./configure --with-pydebug --with-openssl=$PWD/multissl/openssl/4.0.0-alpha1/
make

I fixed a few more issues, but make fails with OPENSSL_sk_set_thunks missing symbol:

[ERROR] _ssl failed to import: /home/vstinner/python/main/build/lib.linux-x86_64-3.15/_ssl.cpython-315d-x86_64-linux-gnu.so: undefined symbol: OPENSSL_sk_set_thunks
[ERROR] _ssl (/home/vstinner/python/main/build/lib.linux-x86_64-3.15/_ssl.cpython-315d-x86_64-linux-gnu.so) is missing

@vstinner

Copy link
Copy Markdown
MemberAuthor

there's a missing symlink (or openssl is just looking in the wrong place) for lib -> lib64 in the openssl install directory.

I fixed that with a5152be.

@heitbaum

Copy link
Copy Markdown
Contributor

Tested results in #146207 (comment)

@vstinner
vstinner marked this pull request as ready for review March 21, 2026 09:50
@vstinnervstinner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 21, 2026
@vstinner

Copy link
Copy Markdown
MemberAuthor

@picnixz@gpshead@zware: Would you mind to review this change?

I reverted the change to run "Tests / Ubuntu SSL tests (ubuntu-24.04, openssl, 4.0.0-alpha1)" CI job. I don't think that we should test alpha versions in our CI.

There are still two test_urllib2_localnet failures that I failed to fix. I cannot test OpenSSL 4 locally (on Fedora), I get an error about the OPENSSL_sk_set_thunks symbol (the CI wasn't impacted by this issue). IMO this PR is good enough for a first step to support OpenSSL 4.

Also, I think that we should backport the change to Python 3.13 and 3.14 to also prepare these branches to OpenSSL 4.

@picnixz

Copy link
Copy Markdown
Member

I am not very fond of adding support in stable branches for an alpha version for now as I do not know if/how the ABI could change.

I do not mind having a presupport in 3.15 so that we can get feedback during our beta but I will take a look at what is planned in OpenSSL once I am at home.

@vstinner
vstinner merged commit 3364e7e into python:mainMar 25, 2026
49 checks passed
@vstinner
vstinner deleted the openssl4 branch March 25, 2026 06:44
@miss-islington-app

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 25, 2026
OpenSSL 4.0.0 alpha1 removed these functions:
* SSLv3_method()
* TLSv1_method()
* TLSv1_1_method()
* TLSv1_2_method()
Other changes:
* Update test_openssl_version().
* Update multissltests.py for OpenSSL 4.
* Add const qualifier to fix compiler warnings.
(cherry picked from commit 3364e7e)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-app

Copy link
Copy Markdown

GH-146403 is a backport of this pull request to the 3.14 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 25, 2026
OpenSSL 4.0.0 alpha1 removed these functions:
* SSLv3_method()
* TLSv1_method()
* TLSv1_1_method()
* TLSv1_2_method()
Other changes:
* Update test_openssl_version().
* Update multissltests.py for OpenSSL 4.
* Add const qualifier to fix compiler warnings.
(cherry picked from commit 3364e7e)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@bedevere-appbedevere-appBot removed the needs backport to 3.14 bugs and security fixes label Mar 25, 2026
@bedevere-app

Copy link
Copy Markdown

GH-146404 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.13 bugs and security fixes label Mar 25, 2026
@vstinner

Copy link
Copy Markdown
MemberAuthor

I merged my PR. Thanks for reviews.

@picnixz:

I am not very fond of adding support in stable branches for an alpha version for now as I do not know if/how the ABI could change.

Oops, I forgot to remove "backport" labels. I closed the 3.13 and 3.14 backport PRs (without merging them).

@vstinner

Copy link
Copy Markdown
MemberAuthor

Oh, I understood the OPENSSL_sk_set_thunks symbol error: make clean removes all .so files and so removes libcrypto.so and libssl.so :-D The solution is to not run make clean or to create multissl/ directory outside CPython source tree. The workaround is to recreate the symlinks manually:

cd multissl/openssl/4.0.0-alpha1/lib64
ln -s libcrypto.so.4 libcrypto.so
ln -s libssl.so.4 libssl.so

@hugovk

Copy link
Copy Markdown
Member

See also #148292 for ssl.SSLError: A failure in the SSL library occurred with 4.0.0-beta1.

@thesamesam

Copy link
Copy Markdown
Contributor

@vstinner@picnixz Could we reopen the backport PRs? 4.0.0 final is out now. I have to admit I wasn't expecting it so soon either..

@vstinner

Copy link
Copy Markdown
MemberAuthor

@vstinner@picnixz Could we reopen the backport PRs? 4.0.0 final is out now. I have to admit I wasn't expecting it so soon either.

I created #148600 for OpenSSL 4.0.0 final. I'm also surprised with the short delay between the alpha1 and the final release (1 month and 4 days).

@picnixz

Copy link
Copy Markdown
Member

I don't want to backport anything until we fixed the tests. I also don't want to backport anything until we have more feedback from the 3.15's beta. We can always backport OSSL 4.x support later for 3.13 and 3.14.

clin1234 pushed a commit to clin1234/cpython that referenced this pull request Apr 16, 2026
OpenSSL 4.0.0 alpha1 removed these functions:
* SSLv3_method()
* TLSv1_method()
* TLSv1_1_method()
* TLSv1_2_method()
Other changes:
* Update test_openssl_version().
* Update multissltests.py for OpenSSL 4.
* Add const qualifier to fix compiler warnings.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
SquallATF pushed a commit to SquallATF/cpython-mingw that referenced this pull request Apr 22, 2026
OpenSSL 4.0.0 alpha1 removed these functions:
* SSLv3_method()
* TLSv1_method()
* TLSv1_1_method()
* TLSv1_2_method()
Other changes:
* Update test_openssl_version().
* Update multissltests.py for OpenSSL 4.
* Add const qualifier to fix compiler warnings.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
OpenSSL 4.0.0 alpha1 removed these functions:
* SSLv3_method()
* TLSv1_method()
* TLSv1_1_method()
* TLSv1_2_method()
Other changes:
* Update test_openssl_version().
* Update multissltests.py for OpenSSL 4.
* Add const qualifier to fix compiler warnings.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
debarshiray pushed a commit to TristanCacqueray/toolbox that referenced this pull request Jul 23, 2026
The default Python stack in Fedora Rawhide was updated from version 3.14
to 3.15 [1], and OpenSSL 4.0 was introduced [2]. As a result of this
combination, the PROTOCOL_TLSv1 attribute disappeared from Python's ssl
module [3]. This prevents Zuul from working with Fedora Rawhide hosts,
because of this Ansible error:
TASK [add-build-sshkey : Enable access via build key on all nodes] ***
An exception occurred during task execution. To see the full
traceback, use -vvv.
The error was: AttributeError: module 'ssl' has no attribute
'PROTOCOL_TLSv1'. Did you mean '.PROTOCOL_TLS' instead of
'.PROTOCOL_TLSv1'?
The use of ssl.PROTOCOL_TLSv1 was removed from ansible-core 2.17.0 [4],
which became available in Ansible 10 [5]; and since Zuul 13.0.0, the
default Ansible version is 9, and version 11 can be optionally used.
Therefore, explicitly selecting Ansible 11 resolves this breakage when
the combination of Python 3.15 and OpenSSL 4.0 are used.
[1] https://fedoraproject.org/wiki/Changes/Python3.15
[2] https://fedoraproject.org/wiki/Changes/OpenSSL40
[3] CPython commit 3364e7e62fa24d0e
python/cpython@3364e7e62fa24d0epython/cpython#146217python/cpython#146207
[4] ansible-core commit 92d2c66db2eecd0f
ansible/ansible@92d2c66db2eecd0fansible/ansible#81880
[5] https://github.com/ansible-community/ansible-build-data/blob/main/10/CHANGELOG-v10.md
[6] https://zuul-ci.org/docs/zuul/latest/releasenotes.htmlcontainers#1824
Signed-off-by: Tristan Cacqueray <tdecacqu@redhat.com>
debarshiray pushed a commit to TristanCacqueray/toolbox that referenced this pull request Jul 24, 2026
The default Python stack in Fedora Rawhide was updated from version 3.14
to 3.15 [1], and OpenSSL 4.0 was introduced [2]. As a result of this
combination, the PROTOCOL_TLSv1 attribute disappeared from Python's ssl
module [3]. This prevents Zuul from working with Fedora Rawhide hosts,
because of this Ansible error:
TASK [add-build-sshkey : Enable access via build key on all nodes] ***
An exception occurred during task execution. To see the full
traceback, use -vvv.
The error was: AttributeError: module 'ssl' has no attribute
'PROTOCOL_TLSv1'. Did you mean '.PROTOCOL_TLS' instead of
'.PROTOCOL_TLSv1'?
The use of ssl.PROTOCOL_TLSv1 was removed from ansible-core 2.17.0 [4],
which became available in Ansible 10 [5,6]; and since Zuul 13.0.0, the
default Ansible version is 9, and version 11 can be optionally used [7].
Therefore, explicitly selecting Ansible 11 resolves this breakage when
the combination of Python 3.15 and OpenSSL 4.0 are used.
[1] https://fedoraproject.org/wiki/Changes/Python3.15
[2] https://fedoraproject.org/wiki/Changes/OpenSSL40
[3] CPython commit 3364e7e62fa24d0e
python/cpython@3364e7e62fa24d0epython/cpython#146217python/cpython#146207
[4] ansible-core commit 92d2c66db2eecd0f
ansible/ansible@92d2c66db2eecd0fansible/ansible#81880
[5] https://docs.ansible.com/projects/ansible/latest/reference_appendices/release_and_maintenance.html
[6] https://github.com/ansible-community/ansible-build-data/blob/main/10/CHANGELOG-v10.md
[7] https://zuul-ci.org/docs/zuul/latest/releasenotes.htmlcontainers#1824
Signed-off-by: Tristan Cacqueray <tdecacqu@redhat.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@vstinner@zware@heitbaum@picnixz@hugovk@thesamesam