Skip to content

openssl: fall back to the default profile CA bundle on Linux; prefer /etc bundle on Darwin - #570263

Merged
reckenrode merged 2 commits into
NixOS:stagingfrom
booxter:openssl-fallback-paths
Oct 27, 2026
Merged

reckenrode merged 2 commits into
NixOS:stagingfrom
booxter:openssl-fallback-paths

Conversation

@booxter

@booxter booxter commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Prefer the system bundle on Linux and Darwin. Fall back to the default
Nix profile only when it is absent, preserving explicit overrides and
failures for unusable system bundles.

This lets Git find the nix-darwin bundle when sudo clears
NIX_SSL_CERT_FILE. Add Linux VM coverage for bundle selection and
override precedence.

This should render hacks like nix-darwin/nix-darwin#1868
unnecessary.


Demonstration of the problem:

>  sudo env GIT_TRACE_CURL=1 GIT_TRACE_CURL_NO_DATA=1 \
    git ls-remote https://github.com/NixOS/nixpkgs.git HEAD 2>&1 \
    | rg 'fallback'
17:51:04.763894 http.c:912              == Info:   OpenSSL default paths (fallback)
>  cat ca-path.c
#include <stdio.h>
#include <openssl/x509.h>

int main(void)
{
    puts(X509_get_default_cert_file());
    return 0;
}
>  ./ca-path
/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt

And the profile is 1 years+ old: it was initialized when I installed Lix on this machine and since it's not managed, it retains an old bundle.

>  /bin/ls -ldT /nix/var/nix/profiles/default
lrwxr-xr-x  1 root  wheel  43 Jul  2 18:07:07 2025 /nix/var/nix/profiles/default -> /nix/var/nix/profiles/per-user/root/profile

Things done

nixpkgs-branch-check[bot]

This comment was marked as outdated.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. llm-assisted Contributions that include code generation with LLMs labels Oct 4, 2026
@booxter
booxter force-pushed the openssl-fallback-paths branch from 2d199b9 to 5e3f70f Compare October 4, 2026 20:20
@booxter
booxter changed the base branch from master to staging October 4, 2026 23:02
@nixpkgs-ci nixpkgs-ci Bot closed this Oct 4, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Oct 4, 2026
@nixpkgs-branch-check
nixpkgs-branch-check Bot dismissed their stale review October 4, 2026 23:12

Review dismissed automatically

@booxter
booxter marked this pull request as ready for review October 5, 2026 00:12
@booxter
booxter requested review from a team and thillux October 5, 2026 00:18
@nixpkgs-ci
nixpkgs-ci Bot requested review from a team and andir and removed request for a team October 5, 2026 00:29
@thillux

thillux commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

We already started discussing this in #472492. IMHO, I'd prefer not to do this. I like to be able to point to different CA bundles in the nix store and not a global one in /etc.

@booxter

booxter commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

I like to be able to point to different CA bundles in the nix store and not a global one in /etc.

I don't think your ability to do it with a wrapper that would set NIX_SSL_CERT_FILE or SSL_CERT_FILE is impeded here?


This PR is doing two behavioral changes:

  1. for linux, if /etc/ssl/certs/ca-certificates.crt doesn't exist, then fall back to nix profile bundle.
  2. for darwin, if /etc/ssl/certs/ca-certificates.crt exists, prefer it, before falling back to nix profile bundle.

(1) and (2) combined make for unified experience on both platforms:

  1. if /etc bundle exists, prefer it (deployed either by NixOS modules or nix-darwin modules, or another distro specific means).
  2. if it doesn't exist, fall back to nix profile bundle. (This is a scenario of non-NixOS linux with non-conventional system bundle location, or when running on macOS without nix-darwin.)

Regardless, you can still set the above mentioned variables at will. This doesn't change.


Which exact behavior of what is listed above do you find objectionable?

@thillux

thillux commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

We already started discussing this in #472492. IMHO, I'd prefer not to do this. I like to be able to point to different CA bundles in the nix store and not a global one in /etc.

Sry, misread this. The other PR was about a global config file.

@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 17, 2026

@zimbatm zimbatm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT, great that this is getting fixed after so many years

@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Oct 20, 2026
@hesiod hesiod added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 21, 2026
@booxter
booxter force-pushed the openssl-fallback-paths branch from 5e3f70f to b1820a3 Compare October 21, 2026 00:35
@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 21, 2026
@booxter

booxter commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@zimbatm rebased as discussed

@booxter

booxter commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

I'll add a release note for this change so there are fewer surprises.

@booxter
booxter marked this pull request as ready for review October 22, 2026 00:40

@nixpkgs-ci nixpkgs-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to the documentation.

Follow the documentation style guide, especially:

  • Show, don’t tell. Start with a minimal working example. Explain after the code.
  • Avoid meta-commentary. Don’t write "This section explains how to…".
  • Use present tense, imperative mood, and active voice. For example: "Run the command," not "The user should run the following command."
  • Avoid vague references like "this" when the referent is unclear. Write "This command creates a folder," not "This will create a folder."
  • Be direct. Avoid "should", "might", "typically", and "usually".
  • Cut filler words like "simply", "just", "easily", and "basically". Use "to" instead of "in order to".

For larger changes, such as adding or removing whole sections, ask the NixOS documentation team for review.

@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team October 22, 2026 00:50
@nixpkgs-ci nixpkgs-ci Bot added 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation labels Oct 22, 2026
@booxter

booxter commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

One thing I'm not clear on is: do we want to see this backported? It's a behavioral change, but one that allows to avoid using the potentially insecure Nix profile bundle in particular scenarios (under sudo). (I'm talking about Darwin part of the change; Linux change doesn't have this security angle.)

@booxter booxter changed the title openssl: fall back to the default profile CA bundle openssl: fall back to the default profile CA bundle on Linux; prefer /etc bundle on darwin Oct 24, 2026
@booxter booxter changed the title openssl: fall back to the default profile CA bundle on Linux; prefer /etc bundle on darwin openssl: fall back to the default profile CA bundle on Linux; prefer /etc bundle on Darwin Oct 24, 2026
Prefer the system bundle on Linux and Darwin. Fall back to the default
Nix profile only when it is absent, preserving explicit overrides and
failures for unusable system bundles.

This lets Git find the nix-darwin bundle when sudo clears
NIX_SSL_CERT_FILE. Add Linux VM coverage for bundle selection and
override precedence.

This should render hacks like github.com/nix-darwin/nix-darwin/pull/1868
unnecessary.

Assisted-by: Codex, GPT-6.1-Sol medium
@Scrumplex

Copy link
Copy Markdown
Member

Not really breaking for 26.11. This can therefore be merged whenever you want :D

@reckenrode reckenrode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for Darwin.

@reckenrode
reckenrode added this pull request to the merge queue Oct 27, 2026
Merged via the queue into NixOS:staging with commit 3744285 Oct 27, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.severity: security Issues which raise a security issue, or PRs that fix one 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants