diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2023-03-27 15:37:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-27 15:37:15 +0200 |
commit | 5a0f5b5c34d90fe6515d23446402c491b992a99b (patch) | |
tree | 5678953d71137ec0e114ccbc604805b52799c4fa /src/libstore/globals.cc | |
parent | 570829d67e78d97d53a935e4e61b0a09589c4cd1 (diff) | |
parent | a519436e9d78fa6500999485c2c638553a32696f (diff) |
Merge pull request #8062 from edolstra/ssl-cert-file
Add a setting for configuring the SSL certificates file
Diffstat (limited to 'src/libstore/globals.cc')
-rw-r--r-- | src/libstore/globals.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 8781e10ea..823b4af74 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -44,14 +44,9 @@ Settings::Settings() lockCPU = getEnv("NIX_AFFINITY_HACK") == "1"; allowSymlinkedStore = getEnv("NIX_IGNORE_SYMLINK_STORE") == "1"; - caFile = getEnv("NIX_SSL_CERT_FILE").value_or(getEnv("SSL_CERT_FILE").value_or("")); - if (caFile == "") { - for (auto & fn : {"/etc/ssl/certs/ca-certificates.crt", "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"}) - if (pathExists(fn)) { - caFile = fn; - break; - } - } + auto sslOverride = getEnv("NIX_SSL_CERT_FILE").value_or(getEnv("SSL_CERT_FILE").value_or("")); + if (sslOverride != "") + caFile = sslOverride; /* Backwards compatibility. */ auto s = getEnv("NIX_REMOTE_SYSTEMS"); @@ -175,6 +170,13 @@ bool Settings::isWSL1() return hasSuffix(utsbuf.release, "-Microsoft"); } +Path Settings::getDefaultSSLCertFile() +{ + for (auto & fn : {"/etc/ssl/certs/ca-certificates.crt", "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"}) + if (pathExists(fn)) return fn; + return ""; +} + const std::string nixVersion = PACKAGE_VERSION; NLOHMANN_JSON_SERIALIZE_ENUM(SandboxMode, { |