Add CA certificates for curl HTTPS in containers#232
Merged
Conversation
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
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.
3 tasks
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.
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.
Summary
pkgs.cacerttoruntimeInputsofwrapped-cabalin all 4 shell configurations (dynamic, static, cross-js, cross-windows)cacertpackage provides a setup-hook that setsSSL_CERT_FILE,NIX_SSL_CERT_FILE, andSYSTEM_CERTIFICATE_PATHbuildCommandfix, this ensures curl can verify HTTPS certificates in-envcontainersProblem
After PR #231 fixed the
nix-support/propagated-native-build-inputsfile 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:Fix
Adding
cacerttoruntimeInputspropagates it through thenix-support/file. Whensetup.sh'sfindInputsprocesses the wrapper, it discoverscacertand runs its setup-hook, which sets the SSL environment variables pointing to the Nix store's CA bundle.Test plan