Repository navigation
python3Packages.certifi: use system certificate bundle - #589174
Skyb0rg007 wants to merge 2 commits into
Conversation
Review dismissed automatically
d21eb1c to
a1d42e4
Compare
a1d42e4 to
2263173
Compare
The certifi.where() function now uses the $NIX_SSL_CERT_FILE environment variable, falling back to a list of common system locations. This removes cacert from the runtime closure of the package.
python3Packages.certifi doesn't have cacert in propagagedBuildInputs, so dependencies that need access to CA certificates inside the sandbox (often for tests) now need to add cacert to nativeCheckInputs.
2263173 to
5edb2fa
Compare
| # Use our system-wide ca-bundle instead of the bundled one | ||
| rm -v "certifi/cacert.pem" | ||
| ln -snvf "${cacert}/etc/ssl/certs/ca-bundle.crt" "certifi/cacert.pem" | ||
| rm -v certifi/{core.py,cacert.pem} | ||
| cp "${./core.py}" "certifi/core.py" |
There was a problem hiding this comment.
So the original code already replaced the certificate bundle with the system one. Am I misunderstanding something, or is this just achieving the same thing with a bigger diff?
There was a problem hiding this comment.
It's making sure we use the cacert that's a part of the running system. This means nix run some-old-flake#python3Packages.somepkg https://example.com would use the up-to-date certificates in /etc instead of the out-of-date certificates in the runtime closure.
This ensures future eMudhra-style events don't make nix packages insecure, as the package will always delegate the certificate bundle to the system
There was a problem hiding this comment.
No, I understand the intent, but the original code already replaced certifi/cacert.pem with a symlink to the CA bundle in the cacert package. The only difference I see here is that if the NIX_SSL_CERT_FILE is not set, your change makes certifi fall back to the system certificate bundle, which seems less secure.
There was a problem hiding this comment.
the original code already replaced
certifi/cacert.pemwith a symlink to the CA bundle in the cacert package.
Which is less secure.
For example, a project might include a shell.nix which pins project dependencies. If that project uses certifi to download files, then any certificate changes the system administrator tries to enforce are moot: the packages will use the cacert from the pinned nixpkgs (which may include certificates the admin doesn't want to trust like eMudhra or doesn't include their own certificates that they want to trust for their own personal domains).
This removes certifi's dependency on the Nix store cacert package, instead looking at the path specified in the NIX_SSL_CERT_FILE environment variable, the /etc/ssl/certs/ca-certificates.crt file, or a short list of other common system CA bundle locations.
Instead of using a patch file, the entire
core.pyfile is replaced. The simplifications are safe to perform; the rewrite is modeled after Debian's certifi patch.This is an important step to removing the
cacertpackage from nixpkgs packages' runtime closures. The currently trusted CA certificates are a property of a running system: embedding them into the derivation doesn't improve purity, it just makes it harder to be secure. Instead, thecacertpackage should be listed as anativeCheckInputwhen needed. While #578494 is a partial solution to this problem, nixpkgs packages should not rely on an environment variable being set to not be insecure.Related to #8247
A warning: the treewide commit is not complete - there will likely need to be follow-up fixes for other leaf packages that depend on
certifi. The treewide commit here only covers the derivations with the most number of nixpkgs rebuilds.Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.