Skip to content

Add CA certificates for curl HTTPS in containers#232

Merged
angerman merged 1 commit into
mainfrom
fix/cacert-for-curl
Feb 25, 2026
Merged

Add CA certificates for curl HTTPS in containers#232
angerman merged 1 commit into
mainfrom
fix/cacert-for-curl

Conversation

@angerman
Copy link
Copy Markdown
Collaborator

Summary

  • Add pkgs.cacert to runtimeInputs of wrapped-cabal in all 4 shell configurations (dynamic, static, cross-js, cross-windows)
  • The cacert package provides a setup-hook that sets SSL_CERT_FILE, NIX_SSL_CERT_FILE, and SYSTEM_CERTIFICATE_PATH
  • Combined with PR Fix: materialize propagatedNativeBuildInputs file for runtimeInputs propagation #231's buildCommand fix, this ensures curl can verify HTTPS certificates in -env containers

Problem

After PR #231 fixed the nix-support/propagated-native-build-inputs file creation, curl became available on PATH in containers. However, in rootless containers (no system CA store), OpenSSL falls back to /no-cert-file.crt — a sentinel value indicating no CA bundle is configured:

curl: (77) error adding trust anchors from file: /no-cert-file.crt

Fix

Adding cacert to runtimeInputs propagates it through the nix-support/ file. When setup.sh's findInputs processes the wrapper, it discovers cacert and runs its setup-hook, which sets the SSL environment variables pointing to the Nix store's CA bundle.

Test plan

curl requires CA certificates to validate HTTPS connections. In the
-env containers (rootless, no system CA store), OpenSSL falls back to
/no-cert-file.crt when cacert is not in the dependency closure. Adding
pkgs.cacert to runtimeInputs propagates it through nix-support/, and
its setup-hook sets SSL_CERT_FILE, NIX_SSL_CERT_FILE, and
SYSTEM_CERTIFICATE_PATH — enabling curl to verify HTTPS certificates
in the container environment.

Fixes: curl: (77) error adding trust anchors from file: /no-cert-file.crt
@angerman angerman added this pull request to the merge queue Feb 25, 2026
Merged via the queue into main with commit 4aaa200 Feb 25, 2026
0 of 6 checks passed
@angerman angerman deleted the fix/cacert-for-curl branch February 25, 2026 14:35
angerman added a commit that referenced this pull request Feb 25, 2026
curl does NOT check SSL_CERT_FILE — it only checks CURL_CA_BUNDLE and
its built-in CA bundle path. The nixpkgs-built curl has /no-cert-file.crt
as its built-in path (a sentinel when cacert is absent at build time).

The cacert setup-hook (from PR #232) sets SSL_CERT_FILE but not
CURL_CA_BUNDLE, so curl still fails in containers with:
  curl: (77) error adding trust anchors from file: /no-cert-file.crt

Set both CURL_CA_BUNDLE (for curl) and SSL_CERT_FILE (for OpenSSL-based
tools) directly in mkShell to ensure CA certificates are found regardless
of whether the cacert setup-hook has run.
github-merge-queue Bot pushed a commit that referenced this pull request Feb 25, 2026
curl does NOT check SSL_CERT_FILE — it only checks CURL_CA_BUNDLE and
its built-in CA bundle path. The nixpkgs-built curl has /no-cert-file.crt
as its built-in path (a sentinel when cacert is absent at build time).

The cacert setup-hook (from PR #232) sets SSL_CERT_FILE but not
CURL_CA_BUNDLE, so curl still fails in containers with:
  curl: (77) error adding trust anchors from file: /no-cert-file.crt

Set both CURL_CA_BUNDLE (for curl) and SSL_CERT_FILE (for OpenSSL-based
tools) directly in mkShell to ensure CA certificates are found regardless
of whether the cacert setup-hook has run.
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