Skip to content

[3.14] gh-148292: Add OpenSSL 4 support - #149783

Closed
vstinner wants to merge 6 commits into
python:3.14from
vstinner:openssl4
Closed

vstinner wants to merge 6 commits into
python:3.14from
vstinner:openssl4

Conversation

@vstinner

@vstinner vstinner commented May 13, 2026 •

Copy link
Copy Markdown
Member

vstinner and others added 5 commits May 13, 2026 17:02
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 <[email protected]>
(cherry picked from commit 3364e7e)
The Modules/_ssl_data_40.h file was created with the commands:

python Tools/ssl/multissltests.py --steps=library --base-directory "$PWD/multissl" --openssl '4.0.0' --system Linux
python Tools/ssl/make_ssl_data.py multissl/src/openssl-4.0.0 Modules/_ssl_data_40.h

Update Modules/_ssl.c to include it on OpenSSL 4.0.0 and newer.

Update test_ssl for the new error message.

(cherry picked from commit 70eb56b)
The _SSLSocket object now remembers if it gets an EOF error. In this
case, read(), sendfile(), write() and do_handshake method calls fail
with SSLEOFError without calling the underlying OpenSSL function.

Co-authored-by: Gregory P. Smith <[email protected]>
(cherry picked from commit 7b7fa3f)
…ython#149366)

The shutdown() behavior depends too much on the operating system and
it's unrelated to the got_eof_error change.

(cherry picked from commit 1e21cf6)
@vstinner

Copy link
Copy Markdown
Member Author

@picnixz @gpshead: Would you mind to review this change? Are you ok with backporting OpenSSL 4.0.0 support to Python 3.13 and 3.14 branches?

@vstinner

Copy link
Copy Markdown
Member Author

Ping @picnixz @gpshead. Are you ok with adding OpenSSL 4.0.0 support for Python 3.14?

@picnixz

picnixz commented May 21, 2026

Copy link
Copy Markdown
Member

Can we wait a bit before doing so? I do not want to fix openssl issues arising in a bugfix because we added support for OSSL4. It is a major change and for instance, I did not backport the use of the EVP API introduced in 3.x for HMAC to older releases.

I really want to wait for users to test 3.15 with 4.0, say until aftrr 3.15.1, and we can add it to 3.14 afterwards. It would not help backports though as each version has its own ssl.c (almost)

@vstinner

Copy link
Copy Markdown
Member Author

Ok, in this case, I prefer closing my PR. For my own workflow, I prefer to not keep PRs opens for too long. The PR can be reopened/recreated later.

@vstinner vstinner closed this May 21, 2026
@vstinner
vstinner deleted the openssl4 branch May 21, 2026 11:35
@native-api

Copy link
Copy Markdown
Contributor

@vstinner We have applied this backport downstream in Pyenv so that users can link against OpenSSL 4 if they wish / if it's the default on their system.

Is it reasonable to expect that if there are further OpenSSL 4 -- related fixes before the official backport, they will be added to this PR?

@vstinner

vstinner commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

We can revisit (reopen) this PR later. If this PR is reopened, we will add further changes if there are more OpenSSL 4.0 changes.

@picnixz would like to wait for user feedback testing Python 3.15 with OpenSSL 4.0.

@picnixz

picnixz commented Jun 1, 2026

Copy link
Copy Markdown
Member

Yes I want to wait at least until 3.15.0 is out and we can reconsider this in 3.15.1.

@thesamesam

thesamesam commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Could this one be reconsidered now please? OpenSSL 3.6.x is EOL, so people are stuck on 3.5.x or >=4.x now.

3.15 seems okay for me except for:

@picnixz

picnixz commented Oct 31, 2026

Copy link
Copy Markdown
Member

OpenSSL 3.6.x is EOL

Wow, I thought 3.6 was the LTS and not 3.5 (I think I was biased bc of Python 3.6 which lasted longer in many distros compared to 3.5). I don't think being "stuck" in 3.5 is a problem though (but I may once again have mixed the supported features).

That being said, let's first fix the 4.x support in 3.15+ before backporting anything, indeed.

evanspearman pushed a commit to evanspearman/pkgs that referenced this pull request Nov 25, 2026
…s 2026-11-01) (gominimal#1140)

* openssl: 4.1.0 (3.6 support ends 2026-11-01)

OpenSSL 3.6 is supported until 2026-11-01; 4.1 until Nov 2027
(openssl-library.org/source). sha256 is the release's published
openssl-4.1.0.tar.gz.sha256 (verified against a download).

4.x layout changes reflected in outputs:
- SHLIB_VERSION=4: libssl.so.4 / libcrypto.so.4. Every symbol is
  versioned OPENSSL_4.0.0, so it can coexist with libssl.so.3 from
  packages/openssl-3.5 in one process.
- c_rehash removed (use `openssl rehash`); dropped its output.
- ENGINE support removed: no engines-3 directory; dropped its output.
- ossl-modules now globs usr/lib/ossl-modules (it pointed at
  engines-3, so legacy.so was never shipped).

--openssldir=/etc/ssl, --libdir=lib, shared, zlib-dynamic unchanged;
all are still valid 4.x Configure options. build.sh now fails closed
if the .so.4 / ossl-modules layout is missing.

DRAFT, NOT PUSHED: the tarball is not yet mirrored to
gs://minimal-staging-archives/openssl/openssl/openssl-4.1.0.tar.gz.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* openssl-3.5: new compat package (3.5.9 LTS, libssl.so.3 beside 4.x)

OpenSSL 3.5 is the LTS line (supported to 2030-04-08). This package
ships its libssl.so.3 / libcrypto.so.3 on the default loader path and
a dev tree under /usr/lib/openssl-3.5, so code that cannot use 4.x keeps
working after packages/openssl moves to 4.1:

- rustc-1.98.1's stage0: both sealed rustc-1.97.1 bedrock tarballs ship
  a cargo with DT_NEEDED libssl.so.3 + libcrypto.so.3 (read from the
  amd64 and arm64 tarballs' ELF dynamic sections).
- actions-runner 2.336.0 bundles .NET 8 (global.json sdk 8.0.422); only
  .NET 10 got the OpenSSL 4 loader (dotnet/runtime#135534).
- foundationdb 7.3, whose C++ does not compile against 4.x's const X509
  API; upstream is itself moving to a pinned 3.5 (apple/foundationdb#14348).

Nothing collides with packages/openssl: no /usr/bin, /usr/include,
/usr/lib/pkgconfig or /etc/ssl files. OPENSSLDIR stays /etc/ssl, so the
CA store and openssl.cnf are shared. Symbol versions differ
(OPENSSL_3.x vs OPENSSL_4.0.0), so one process can load both.

The package name carries the series, so pkgmgr's name pin keeps it on
3.5.x. sha256 is the release's published openssl-3.5.9.tar.gz.sha256
(verified against a download). DRAFT, NOT PUSHED: not yet mirrored to
gs://minimal-staging-archives/openssl/openssl/openssl-3.5.9.tar.gz.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* rustc-1.98.1: give the bedrock stage0 its libssl.so.3 (openssl-3.5)

Both sealed rustc-1.97.1 bedrock tarballs (amd64 6ec57e96..., arm64
de0724a4...) ship usr/lib/rustc-1.97.1/bin/cargo with DT_NEEDED
libssl.so.3 and libcrypto.so.3. With packages/openssl on 4.x only
libssl.so.4 exists, so the stage0 cargo would fail to load and the rung,
packages/rust and every Rust package behind it would fail on both arches.

openssl-3.5 goes into the amd64 bedrock spec's runtime_deps and into the
rung's build_deps (the arm64 stage0 is a bare Source). The rung's own
cargo still builds against 4.x: its vendored openssl-sys is 0.9.117.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* actions-runner: runtime-depend on openssl-3.5 (bundled .NET 8 needs libssl.so.3)

actions-runner 2.336.0 bundles .NET 8 (src/global.json sdk 8.0.422).
Its System.Security.Cryptography.Native shim dlopens libssl.so.3 and has
no OpenSSL 4 (.so.4) support: the loader change was backported only to
.NET 10 (dotnet/runtime#135534, merged 2026-10-10; tracking issue
dotnet/runtime#125619 targets 12.0). Without libssl.so.3 every HTTPS
call the runner makes fails at run time once packages/openssl is 4.x.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* python: carry the OpenSSL 4 support for _ssl (cpython#149783, Modules/)

CPython 3.14 has no OpenSSL 4 support: the 3.14 backport,
python/cpython#149783 ("[3.14] gh-148292: Add OpenSSL 4 support"), was
closed unmerged pending 3.15.0 feedback. Unpatched, 3.14.10's _ssl.c
declares and calls SSLv3/TLSv1/TLSv1_1/TLSv1_2_method(), which 4.0
removed, so _ssl.so has unresolved symbols and the ssl module fails to
import.

The patch is the PR's Modules/ hunks (gh-146207 #146217, gh-148600
#148601, gh-148292 #149102, all merged on main): fixed-version methods
treated as absent on 4.x, const X509_NAME/ASN1_STRING accessors,
_ssl_data_40.h, and SSLEOFError bookkeeping for 4.x's EOF behaviour.
Arch Linux carries the same PR in its OpenSSL 4 rebuild. Each hunk is
guarded for 4.x or is a const qualifier, so it is a no-op on OpenSSL 3.
`git apply --check` against v3.14.10's files: applies, offsets only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* socat: ASN1_STRING accessors for OpenSSL 4

OpenSSL 4.0 made ASN1_STRING opaque. socat 1.8.1.3's
openssl_handle_peer_certificate() reads pName->d.iPAddress->data and
->length directly, a hard compile error on 4.x. Carry Debian's
1.8.1.3-2 patch (10-Use-OpenSSL-ASN1_STRING-accessor-functions...);
Fedora rawhide carries the identical hunk (socat-1.8.1.0-openssl4.patch).
Checked: applies cleanly to the mirrored tarball (sha256 06602ffd...).
No-op on OpenSSL 3. socat's fixed-version method calls are behind
configure HAVE_ checks, so they drop out on 4.x by themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* codex, sccache, zellij: lock openssl-sys 0.9.117 for OpenSSL 4

openssl-sys before 0.9.114 aborts in its build script on OpenSSL 4
("This crate is only compatible with OpenSSL (version 1.1.0, 1.1.1, or
3.x)"); 0.9.114 (2026-04-19) added 4.x. These three lock 0.9.111 and
build it against the system library:
- codex 0.164.0: openssl-sys via native-tls on linux-gnu (vendored only
  for musl). Arch hit the same panic: openai/codex#35404 (open).
- sccache 0.18.0: default "all" pulls native-tls; 0.19.0 still locks
  0.9.111. Arch: mozilla/sccache#2780.
- zellij 0.45.1: openssl-sys via isahc's vendored curl-sys, with
  OPENSSL_NO_VENDOR=1.

Each gets a hand-written Cargo.lock patch to openssl-sys 0.9.117 (and
openssl 0.10.81 where it is locked: codex, sccache), the pair Arch pins.
Checksums from the crates.io index; openssl 0.10.81 drops once_cell from
its dependencies, which other crates still use. Each patch was checked
with git apply against upstream's lock at the pinned tag (sccache and
zellij after their webpki lock patch). build.sh fails closed if
0.9.117 is not locked.

Already 4.x-ready, no change: atuin and cloud-hypervisor (0.9.117),
nushell and typst (0.9.116), gurk (no openssl-sys).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* foundationdb: build against openssl-3.5 (7.3 does not compile on OpenSSL 4)

FoundationDB 7.3.79's TLS code assigns X509_get_subject_name() /
X509_get_issuer_name() / X509_NAME_get_entry() / X509_NAME_ENTRY_get_data()
results to non-const pointers (flow/TLSConfig.actor.cpp: X509_NAME
*subject, *issuer; match_name_criteria / match_criteria_entry), and
flow/MkCert.cpp edits a certificate's subject name in place. All four
return const in OpenSSL 4, which is an error in C++. No upstream 4.x
fix exists; upstream is moving the other way, to a pinned 3.5 or
vendored OpenSSL (apple/foundationdb#14348, open).

So build against packages/openssl-3.5: explicit OPENSSL_* CMake cache
variables plus -I on CFLAGS/CXXFLAGS so no translation unit picks up the
4.x headers in /usr/include. build.sh fails closed unless fdbserver and
libfdb_c link libssl.so.3 and not libssl.so.4. Runtime dep switches
from openssl to openssl-3.5.

UNVERIFIED: not built. Header shadowing is the risk to watch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* wget: guard SSLv3_client_method for OpenSSL 4

wget 1.25.0 guards the call with #ifndef OPENSSL_NO_SSL3_METHOD, but
OpenSSL 4 removed the function without defining that macro, so the world
build failed (implicit declaration, openssl.c:230). Also require OpenSSL < 4,
as wget already does for SSLv2. --secure-protocol=SSLv3 then gets no method
and fails cleanly, the same as SSLv2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* zellij: link the system libcurl instead of curl-sys's bundled curl 8.4.0

The world build failed on zellij (both arches): its default `vendored_curl`
feature (isahc/static-curl) compiles curl-sys's bundled curl 8.4.0, which
reads OpenSSL's now-opaque ASN1_INTEGER (vtls/openssl.c:455). Build the other
two default features only, so curl-sys links our libcurl (pkgconf + curl as
build deps, curl libs at runtime), and fail closed unless the binary NEEDs
libcurl.so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* curl: build with HTTP/2 (nghttp2), so curl-sys users link it on OpenSSL 4

zellij still compiled curl-sys's bundled curl 8.4.0 after dropping
vendored_curl: isahc requests http2, and curl-sys falls back to its bundled
copy when `curl-config --features` lacks HTTP2. Our curl had no nghttp2.
Build it with --with-nghttp2 (as Arch/Debian/Fedora do) and fail closed if
configure did not enable it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Revert "curl: build with HTTP/2 (nghttp2), so curl-sys users link it on OpenSSL 4"

This reverts commit 543010e.

* zellij: drop isahc's http2 so curl-sys links the system libcurl (OpenSSL 4)

Dropping vendored_curl was not enough: with isahc's http2 feature on,
curl-sys only links a system libcurl whose curl-config reports HTTP2, and
ours has no nghttp2 (adding it cycles curl -> nghttp2 -> cmake -> curl, so
the curl change is reverted). It then compiled its bundled curl 8.4.0, which
fails on OpenSSL 4's opaque ASN1_INTEGER. The patch removes "http2" from the
isahc declaration plus the matching Cargo.lock edit (libnghttp2-sys), so
--locked still holds; the readelf check still requires libcurl.so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* foundationdb: require libssl.so.3 of fdbserver only; forbid .so.4 everywhere

The world build failed foundationdb's own guard on arm64:
libfdb_c_shim.so "does not link libssl.so.3". The shim dlopen()s libfdb_c at
run time and links no SSL itself, so requiring .so.3 of every libfdb_c*.so
was too strict. Keep the safety property for every ELF we ship (no
libssl/libcrypto .so.4) and fdbserver as the positive control.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci: re-trigger build (or-tools' FetchContent hit GitLab overload cloning eigen)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* zellij: runtime-depend on ca-certificates (system libcurl verifies against /etc/ssl/certs; CR on gominimal#1140)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* or-tools: pinned, mirrored Eigen 3.4.0 + BZip2 instead of build-time GitLab clones

The OpenSSL 4.1 world build failed on or-tools three times today: its
FetchContent git-clones Eigen and BZip2 from gitlab.com, which answered
"unable to handle this request due to load". BZip2 was also pinned only to
GIT_TAG "master". Both are now sha256-pinned Sources mirrored to
gs://minimal-staging-archives (Eigen 3.4.0; BZip2 at master commit 66c46b8c,
2026-10-28), handed to FetchContent through FETCHCONTENT_SOURCE_DIR_EIGEN3 /
_BZIP2, with or-tools' own patches applied as its PATCH_COMMAND would
(checked with git apply --check against these trees). Fails closed if
FetchContent still downloads either. Part of pkgs#1146.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* openssl 4.1: review from msample (python test_ssl hunks, 4.x standalone test, AGENTS.md)

- python: carry the Lib/test/test_ssl.py hunks of cpython#149783 too (rebased
  to 3.14.10, exact context). The shipped test suite failed 6 of 206 test_ssl
  tests against the patched _ssl; these are upstream's matching expectation
  changes, plus test_got_eof for gh-148292. HAS_TLSv1_2 == False is upstream
  gh-159387, noted for the next bump.
- openssl: a standalone `openssl4_behaviour` test, msample's script: .so.4 and no
  engines, the legacy provider + MD4, TLS 1.2 and 1.3 loopback handshakes
  verified against a throwaway P-256 cert by IP SAN.
- openssl-3.5: link the pkgmgr-rs#1140 series pin it relies on (deployed), and
  why it is load-bearing (Repology marks every 3.5.x legacy/outdated).
- wget: the OpenSSL 4 patch applies with -F0 like python/socat's (checked:
  exact context on 1.25.0).
- AGENTS.md: an OpenSSL pattern section: port to 4.x first, openssl-3.5 for
  what can't, how to build/depend/check against it, and 4.1's dropped CN
  fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* openssl: import Test for the openssl4_behaviour standalone test

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants