Repository navigation
nixos/ca: set {NIX_,}SSL_CERT_FILE - #578494
MarcelCoding wants to merge 1 commit into
Conversation
Review dismissed automatically
dotlambda
left a comment
There was a problem hiding this comment.
Should we also set $SSL_CERT_FILE?
|
That's a good question. Possibly yes, but I have tested NIX_SSL_CERT_FILE myself for a longer time and didn't discover any incompatiblies, so it would be the safe bet. |
|
To add some color: I was looking at a similar change in nix-darwin: nix-darwin/nix-darwin#1881 and there's a similar Darwin specific change in home-manager in review: nix-community/home-manager#10112 In my change, I'm trying to retain a user setting if it's explicitly set. Not sure if it applies here, but something to consider. @khaneliman with this PR in mind, does Home Manager need to adjust its systemd integration too? |
It was more like a solution for the current state. I think yes, we probable should define some kid of standard, so its not only compatible with nixos but also with homemanager on non-nixos distros or nix-darwin. I have to research for the reason the |
Maybe we should have a soft-rule that derivations should avoid depending on the
Can you link that discussion? I'm unfamiliar. |
|
These two PRs seems to be the importent once about the introduction about |
919c029 to
6af8088
Compare
| systemd.units."service.d/10-SSL_CERT_FILE.conf".text = /* ini */ '' | ||
| [Service] | ||
| Environment=SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt | ||
| Environment=NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt | ||
| ''; |
There was a problem hiding this comment.
ofc there is an option for this: systemd.globalEnvironment
|
I am not convinced this is safe in the current version. There may be scenarios where A user may have the variable specifically pointing to a different bundle to make the confined service work, but if we override it with a drop-in, their Since you are setting these variables unconditionally, users with a custom It would be saf-er if we would avoid setting the variables if any of the two are detected in Obviously, this would complicate the implementation - since now we would have to peek into the environment at eval time. And while it would mostly work, it would not be exhaustive regardless (e.g. How far one has to go to support these situations is of course debatable, so I'm leaving this for consideration, not as a blocking comment. |
Right now, nss-cacert updates need to go though staging and changes to `security.pki.caCertificateBlacklist` (like in NixOS#576390 or like custom user preferences) are not directly picked up by applications using the `cacert` package. This `NIX_` environment variable is patched-in in packages like pythons `certifi` to override the ca bundle at runtime. Additionally also the SSL_CERT_FILE is defined too, for packages supporting it out of the box. Without this change `certifi` still uses an old version of the ca bundle: ``` ❯ nix-shell -p python3Packages.certifi --command 'diff -u $(python -m certifi) /etc/ssl/certs/ca-bundle.crt' --- /nix/store/6x3vic5vm4jzp29yna1qkp0xmf3qm35i-nss-cacert-3.126/etc/ssl/certs/ca-bundle.crt 1970-01-01 01:00:01.000000000 +0100 +++ /etc/ssl/certs/ca-bundle.crt 1970-01-01 01:00:01.000000000 +0100 @@ -1758,8 +1758,15 @@ Comodo AAA Services root Traditional PEM block omitted: this certificate is not trusted for authenticating servers. -Trusted for: +Rejected for: + - 1.3.6.1.5.5.7.3.1 (RFC5280: serverAuth key usage) + - 1.3.6.1.5.5.7.3.2 (RFC5280: clientAuth key usage) + - 1.3.6.1.5.5.7.3.3 (RFC5280: codeSigning key usage) - 1.3.6.1.5.5.7.3.4 (RFC5280: emailProtection key usage) + - 1.3.6.1.5.5.7.3.8 (RFC5280: timeStamping key usage) + - 1.3.6.1.5.5.7.3.5 (RFC2459: ipsecEndSystem key usage) + - 1.3.6.1.5.5.7.3.6 (RFC2459: ipsecTunnel key usage) + - 1.3.6.1.5.5.7.3.7 (RFC2459: ipsecUser key usage) <and some more> ``` With this change `certifi` uses the same bundle as the module system configures: ``` ❯ nix-shell -p python3Packages.certifi --command 'diff -u $(NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt python -m certifi) /etc/ssl/certs/ca-bundle.crt' <no diff> ``` Co-authored-by: Sandro Jäckel <[email protected]>
6af8088 to
f07d5a1
Compare
|
Thx, @SuperSandro2000 fix actually not only fixes the override of (ofc this still has the issue that we set both variables and the application may prefere the one the user did not override) systemd.units."service.d/10-SSL_CERT_FILE.conf".text = lib.mkForce "";
systemd.globalEnvironment.NIX_SSL_CERT_FILE = "hallo";
systemd.services.test = {
wantedBy = [ "default.target" ];
serviceConfig.EnvironmentFile = pkgs.writeText "env" "NIX_SSL_CERT_FILE=test";
script = ''
echo "$NIX_SSL_CERT_FILE"
'';
}; |
|
If Edit: the linked PR is now ready for review |
|
Even if we remove it from certifi, this is still very valuable to get updates quickly into the system. @NixOS/security-review Can you take a look? |
Right now, nss-cacert updates need to go though staging and changes to
security.pki.caCertificateBlacklist(like in #576390 or like custom user preferences) are not directly picked up by applications using thecacertpackage.This environment variable is patched-in in packages like pythons
certifito override the ca bundle at runtime.Without this change
certifistill uses an old version of the ca bundle:With this change
certifiuses the same bundle as the module systemconfigures:
Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.