Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchurl: revert enabling TLS verification when NIX_SSL_CERT_FILE #351420

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkgs/build-support/fetchurl/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ curl=(
--user-agent "curl/$curlVersion Nixpkgs/$nixpkgsVersion"
)

# Default fallback value defined in pkgs/build-support/fetchurl/default.nix
if [ "$SSL_CERT_FILE" == "/no-cert-file.crt" ]; then
if ! [ -f "$SSL_CERT_FILE" ]; then
curl+=(--insecure)
fi

Expand Down
12 changes: 3 additions & 9 deletions pkgs/build-support/fetchurl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -220,26 +220,20 @@ stdenvNoCC.mkDerivation (
# New-style output content requirements.
inherit (hash_) outputHashAlgo outputHash;

# Disable TLS verification only when we know the hash and no credentials are
# needed to access the resource
SSL_CERT_FILE =
let
nixSSLCertFile = builtins.getEnv "NIX_SSL_CERT_FILE";
in
if nixSSLCertFile != "" then
nixSSLCertFile
else if
if
(
hash_.outputHash == ""
|| hash_.outputHash == lib.fakeSha256
|| hash_.outputHash == lib.fakeSha512
|| hash_.outputHash == lib.fakeHash
# Make sure we always enforce TLS verification when credentials
# are needed to access the resource
|| netrcPhase != null
)
then
"${cacert}/etc/ssl/certs/ca-bundle.crt"
else
# Fallback to stdenv default, see pkgs/stdenv/generic/setup.sh
"/no-cert-file.crt";

outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
Expand Down