]> git.ipfire.org Git - thirdparty/git.git/commitdiff
http: add environment variable support for HTTPS proxies
authorJorge Lopez Silva <jalopezsilva@gmail.com>
Wed, 4 Mar 2020 18:40:06 +0000 (18:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2020 20:26:14 +0000 (12:26 -0800)
Add 4 environment variables that can be used to configure the proxy
cert, proxy ssl key, the proxy cert password protected flag, and the
CA info for the proxy.

Documentation for the options was also updated.

Signed-off-by: Jorge Lopez Silva <jalopezsilva@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/http.txt
http.c

index 71babe57c413028a1f623ba986918414dbf876c2..a7a2725f300cd18aa366967e5d96080b12f2dc82 100644 (file)
@@ -31,20 +31,24 @@ http.proxyAuthMethod::
 
 http.proxySSLCert::
        The pathname of a file that stores a client certificate to use to authenticate
-       with an HTTPS proxy.
+       with an HTTPS proxy. Can be overridden by the `GIT_PROXY_SSL_CERT` environment
+       variable.
 
 http.proxySSLKey::
        The pathname of a file that stores a private key to use to authenticate with
-       an HTTPS proxy.
+       an HTTPS proxy. Can be overridden by the `GIT_PROXY_SSL_KEY` environment
+       variable.
 
 http.proxySSLCertPasswordProtected::
        Enable Git's password prompt for the proxy SSL certificate.  Otherwise OpenSSL
        will prompt the user, possibly many times, if the certificate or private key
-       is encrypted.
+       is encrypted. Can be overriden by the `GIT_PROXY_SSL_CERT_PASSWORD_PROTECTED`
+       environment variable.
 
 http.proxySSLCAInfo::
        Pathname to the file containing the certificate bundle that should be used to
-       verify the proxy with when using an HTTPS proxy.
+       verify the proxy with when using an HTTPS proxy. Can be overriden by the
+       `GIT_PROXY_SSL_CAINFO` environment variable.
 
 http.emptyAuth::
        Attempt authentication without seeking a username or password.  This
diff --git a/http.c b/http.c
index 649ee6c6db27ad1d7fe054a2241dfe6770aa02da..6e804b938d4e926dcca351ed7ac071071a05c512 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1211,6 +1211,13 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
                max_requests = DEFAULT_MAX_REQUESTS;
 #endif
 
+       set_from_env(&http_proxy_ssl_cert, "GIT_PROXY_SSL_CERT");
+       set_from_env(&http_proxy_ssl_key, "GIT_PROXY_SSL_KEY");
+       set_from_env(&http_proxy_ssl_ca_info, "GIT_PROXY_SSL_CAINFO");
+
+       if (getenv("GIT_PROXY_SSL_CERT_PASSWORD_PROTECTED"))
+               proxy_ssl_cert_password_required = 1;
+
        if (getenv("GIT_CURL_FTP_NO_EPSV"))
                curl_ftp_no_epsv = 1;