Repository navigation
Conversation
virtualenv ships a pip wheel in virtualenv/seed/wheels/embed and installs it into every venv it makes. That pip adds the cacert.pem of its vendored certifi to the trust store next to the system store. Thus a cacert update alone does not remove a distrusted root (for example emSign ECC Root CA - G3) from pip in such a venv. Rewrite the embedded pip wheel with the same script and override as the cpython ensurepip wheel. The vendored certifi then returns NIX_SSL_CERT_FILE, SSL_CERT_FILE or /etc/ssl/certs/ca-certificates.crt when one exists. The vendored bundle stays as a fallback. The two shared files are byte-identical to the ones from the cpython and python3Packages.pip changes, so the branches merge cleanly. Part of NixOS#576542. Assisted-by: Claude Code (claude-opus-5)
14 of 88 tasks
mBornand
suggested changes
Oct 23, 2026
mBornand
left a comment
Contributor
There was a problem hiding this comment.
Things that I think should be changed
- certifi also has a
contentsfunction that does not use where internally, it should be patched to not return the vendored certs anymore. https://github.com/certifi/python-certifi/blob/b60466c9f2882d9cf088943c650b0faac06c080c/certifi/core.py#L47
Some additional thoughts:
- In addition we could also remove the cacert.pem file completely.
- At some point we are very close to replacing the whole file. (There is also a
exit_cacert_ctxfunction, that might need to be created too)
This review applies also to #576525 #576524
I don't think I am a reference for this but wouldn't the review be easier if it where one PR instead of three?
|
|
||
|
|
||
| def where() -> str: | ||
| return _nix_system_bundle() or _nix_vendored_where() |
Contributor
There was a problem hiding this comment.
Do we really want to fallback to the vendored certs? We could also fallback to the the cacert package.
dotlambda
reviewed
Oct 28, 2026
| hash = "sha256-8LOmA1Mhfqbl3hsGZa8tQutjfjEVeDlpOKyVut5rDVI="; | ||
| }; | ||
|
|
||
| # Make the pip seeded into each venv prefer the system CA bundle over its vendored certifi. |
Member
There was a problem hiding this comment.
Why don't we apply our certifi patch to the vendored certifi?
| postPatch = '' | ||
| for whl in src/virtualenv/seed/wheels/embed/pip-*.whl; do | ||
| old=$(sha256sum "$whl" | cut -d' ' -f1) | ||
| ${python.pythonOnBuildForHost.interpreter} ${../../interpreters/python/cpython/ensurepip-certifi.py} \ |
Member
fixed by #577206 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
virtualenv ships a pip wheel in virtualenv/seed/wheels/embed and installs it into every venv it makes. That pip adds the cacert.pem of its vendored certifi to the trust store next to the system store. Thus a cacert update alone does not remove a distrusted root (for example emSign ECC Root CA - G3) from pip in such a venv.
Rewrite the embedded pip wheel with the same script and override as the cpython ensurepip wheel. The vendored certifi then returns NIX_SSL_CERT_FILE, SSL_CERT_FILE or /etc/ssl/certs/ca-certificates.crt when one exists. The vendored bundle stays as a fallback.
The two shared files are byte-identical to the ones from the cpython and python3Packages.pip changes, so the branches merge cleanly.
Tested on x86_64-linux in a venv made by the patched virtualenv (pip 26.1.2):
certifi.where()returns /etc/ssl/certs/ca-certificates.crt;pip download sixfails with CERTIFICATE_VERIFY_FAILED when SSL_CERT_FILE holds an unrelated self-signed cert, and works with the system bundle. The unpatched wheel downloads even with the bad cert. 237 tests pass. pip-certifi-override.py and ensurepip-certifi.py are byte-identical to #576524 and #576525, so the PRs merge without conflict.Note: virtualenv on staging already fails to build without this change (
filelock<4,>=3.24.2 not satisfied by version 4.1.2); withpythonRelaxDeps = [ "filelock" ]it builds and the tests pass. That needs a separate fix. Also, virtualenv's periodic update can download a newer, unpatched pip into its app-data; this change covers only the embedded wheels.Related to: #576485
Related to: #576542
Assisted-by: Claude Code (claude-opus-5)
Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.