Skip to content

Commit a169553

Browse files
committed
fetchurl: enable TLS verification when credentials are used
This make sure the credentials cannot be leaked in a MITM attack. Note that this change might break some existing deployments if the users tries to fetch resources on endpoints with invalid certificates. The impacted users will have the following choices: * fix the endpoint providing the resource * override SSL_CERT_FILE to either disable the verification (not recommended) or to set it to a path including their CA certificate.
1 parent d81fd7b commit a169553

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkgs/build-support/fetchurl/default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ stdenvNoCC.mkDerivation ((
164164
# New-style output content requirements.
165165
inherit (hash_) outputHashAlgo outputHash;
166166

167-
SSL_CERT_FILE = if (hash_.outputHash == "" || hash_.outputHash == lib.fakeSha256 || hash_.outputHash == lib.fakeSha512 || hash_.outputHash == lib.fakeHash)
167+
# Disable TLS verification only when we know the hash and no credentials are needed to access the ressource
168+
SSL_CERT_FILE = if (hash_.outputHash == "" || hash_.outputHash == lib.fakeSha256 || hash_.outputHash == lib.fakeSha512 || hash_.outputHash == lib.fakeHash || netrcPhase != null)
168169
then "${cacert}/etc/ssl/certs/ca-bundle.crt"
169170
else "/no-cert-file.crt";
170171

0 commit comments

Comments
 (0)