Merge pull request #12275 from Bo98/curl-capath

shims/shared/curl: pass both `--cafile` and `--capath` to override default
This commit is contained in:
Bo Anderson 2021-10-20 16:28:15 +01:00 committed by GitHub
commit 5a5a8d58b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -551,6 +551,7 @@ setup_ca_certificates() {
then then
export SSL_CERT_FILE="${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem" export SSL_CERT_FILE="${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem"
export GIT_SSL_CAINFO="${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem" export GIT_SSL_CAINFO="${HOMEBREW_PREFIX}/etc/ca-certificates/cert.pem"
export GIT_SSL_CAPATH="${HOMEBREW_PREFIX}/etc/ca-certificates"
fi fi
} }
setup_ca_certificates setup_ca_certificates

View File

@ -802,6 +802,7 @@ class FormulaInstaller
if formula.name == "ca-certificates" && if formula.name == "ca-certificates" &&
!DevelopmentTools.ca_file_handles_most_https_certificates? !DevelopmentTools.ca_file_handles_most_https_certificates?
ENV["SSL_CERT_FILE"] = ENV["GIT_SSL_CAINFO"] = formula.pkgetc/"cert.pem" ENV["SSL_CERT_FILE"] = ENV["GIT_SSL_CAINFO"] = formula.pkgetc/"cert.pem"
ENV["GIT_SSL_CAPATH"] = formula.pkgetc
end end
# use installed curl when it's needed and available # use installed curl when it's needed and available

View File

@ -13,6 +13,25 @@ fi
source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh" source "${HOMEBREW_LIBRARY}/Homebrew/shims/utils.sh"
# SSL_CERT_FILE alone does not clear the CAPath setting.
set_certs=0
if [[ -n "${SSL_CERT_FILE}" ]]
then
set_certs=1
for arg in "$@"
do
if [[ "${arg}" =~ --ca(cert|path) ]]
then
# User passed their own settings - don't use ours!
set_certs=0
fi
done
fi
if [[ ${set_certs} -eq 1 ]]
then
set -- "--cacert" "${SSL_CERT_FILE}" "--capath" "$(dirname "${SSL_CERT_FILE}")" "$@"
fi
try_exec_non_system "${HOMEBREW_CURL:-curl}" "$@" try_exec_non_system "${HOMEBREW_CURL:-curl}" "$@"
safe_exec "/usr/bin/curl" "$@" safe_exec "/usr/bin/curl" "$@"