Skip to content

Port cpython 104135#307

Open
dwoz wants to merge 3 commits into
mainfrom
port-cpython-104135
Open

Port cpython 104135#307
dwoz wants to merge 3 commits into
mainfrom
port-cpython-104135

Conversation

@dwoz

@dwoz dwoz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Patch bundled Lib/ssl.py on Windows Python 3.10 / 3.11 to work around cpython#104135.

The pre-fix _load_windows_store_certs concatenated every Windows root-store certificate and handed the blob to OpenSSL, which (3.5.x) rejects the lot on a single ASN.1-malformed cert with [ASN1: NOT_ENOUGH_DATA] — breaking pip-over-HTTPS and any other TLS use inside an onedir.

Upstream merged an iterate-and-skip rewrite for Python 3.12+ but never backported it; relenv now applies the same rewrite at build time. Self-disables on Python 3.12+ and on non-Windows.

dwoz added 2 commits June 24, 2026 18:53
Python 3.10 and 3.11 stdlib's ssl._load_windows_store_certs
concatenates every Windows root-store certificate and feeds the lot
to OpenSSL's load_verify_locations as one cadata blob.  OpenSSL 3.5.x
(shipped since relenv 0.22.13) rejects the entire blob on a single
ASN.1-malformed cert with "[ASN1: NOT_ENOUGH_DATA]", killing every
TLS connection inside the onedir — pip-over-HTTPS, salt-call to a
master, anything.  Upstream merged an iterate-and-skip rewrite onto
the 3.12 branch but never backported it; see
python/cpython#104135.

Append the same iterate-and-skip replacement to the bundled
Lib/ssl.py during the Windows build (relenv/build/windows.py).  The
patch self-disables on Python 3.12+ and on non-Windows, so calling it
unconditionally from the Windows builder is safe.  Idempotent via a
marker comment, and the marker matches the one in Salt's
cicd/windows-ssl-104135-patch.py so an ssl.py patched by either side
is left alone by the other during the transition window.

Once Salt picks up a relenv release carrying this, they drop the
patch script, the three workflow steps in build-deps-ci-action.yml /
test-action.yml / test-packages-action.yml, the salt/__init__.py
monkey-patch, and the salt/ext/tornado/netutil.py certifi pin.

Bumps __version__ to 0.22.15 and adds a CHANGELOG.md entry.
Covers:

- append + marker present on a clean Lib/ssl.py
- idempotency: applying twice leaves exactly one marker block
- missing Lib/ssl.py logs a warning and returns without raising
- appended block compiles cleanly as Python (with SSLError / SSLContext
  stubs to match what ssl.py provides at module scope)

Behaviour of the patched _load_windows_store_certs itself is exercised
end-to-end by Salt's onedir CI on real Windows runners; these unit
tests guard the file plumbing relenv owns.
@dwoz dwoz force-pushed the port-cpython-104135 branch from 7bfb988 to 0f826df Compare June 25, 2026 01:53
Pre-commit ruff-format wanted two blank lines between the new function
and the EnvMapping type alias; CI surfaced this after GitHub's rebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant