Skip to content

Commit

Permalink
Merge branch 'js/https-proxy-config' into pu
Browse files Browse the repository at this point in the history
A handful of options to configure SSL when talking to proxies have
been added.

Not enough review.  Addition of on-disk key looks wrong.

* js/https-proxy-config:
  config: documentation for HTTPS proxy client cert.
  http: add client cert for HTTPS proxies.
  • Loading branch information
gitster committed Mar 3, 2020
2 parents 948dc3b + 8c015f6 commit 652847d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
14 changes: 14 additions & 0 deletions Documentation/config/http.txt
Expand Up @@ -29,6 +29,20 @@ http.proxyAuthMethod::
* `ntlm` - NTLM authentication (compare the --ntlm option of `curl(1)`)
--

http.proxycert::
File indicating a client certificate to use to authenticate with an HTTPS proxy.

http.proxykey::
File indicating a private key to use to authenticate with an HTTPS proxy.

http.proxykeypass::
When communicating to the proxy using TLS (using an HTTPS proxy), use this
option along `http.proxykey` to indicate a password for the key.

http.proxycainfo::
File containing the certificates to verify the proxy with when using an HTTPS
proxy.

http.emptyAuth::
Attempt authentication without seeking a username or password. This
can be used to attempt GSS-Negotiate authentication without specifying
Expand Down
48 changes: 43 additions & 5 deletions http.c
Expand Up @@ -86,6 +86,14 @@ static long curl_low_speed_time = -1;
static int curl_ftp_no_epsv;
static const char *curl_http_proxy;
static const char *http_proxy_authmethod;

#if LIBCURL_VERSION_NUM >= 0x073400
static const char *http_proxy_ssl_cert;
static const char *http_proxy_ssl_key;
static const char *http_proxy_ssl_keypasswd;
#endif
static const char *http_proxy_ssl_ca_info;

static struct {
const char *name;
long curlauth_param;
Expand Down Expand Up @@ -365,6 +373,20 @@ static int http_options(const char *var, const char *value, void *cb)
if (!strcmp("http.proxyauthmethod", var))
return git_config_string(&http_proxy_authmethod, var, value);

#if LIBCURL_VERSION_NUM >= 0x073400
if (!strcmp("http.proxycert", var))
return git_config_string(&http_proxy_ssl_cert, var, value);

if (!strcmp("http.proxykey", var))
return git_config_string(&http_proxy_ssl_key, var, value);

if (!strcmp("http.proxykeypass", var))
return git_config_string(&http_proxy_ssl_keypasswd, var, value);

if (!strcmp("http.proxycainfo", var))
return git_config_string(&http_proxy_ssl_ca_info, var, value);
#endif

if (!strcmp("http.cookiefile", var))
return git_config_pathname(&curl_cookie_file, var, value);
if (!strcmp("http.savecookies", var)) {
Expand Down Expand Up @@ -924,8 +946,14 @@ static CURL *get_curl_handle(void)
#if LIBCURL_VERSION_NUM >= 0x073400
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL);
#endif
} else if (ssl_cainfo != NULL)
curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
} else if (ssl_cainfo != NULL || http_proxy_ssl_ca_info != NULL) {
if (ssl_cainfo != NULL)
curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
#if LIBCURL_VERSION_NUM >= 0x073400
if (http_proxy_ssl_ca_info != NULL)
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, http_proxy_ssl_ca_info);
#endif
}

if (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {
curl_easy_setopt(result, CURLOPT_LOW_SPEED_LIMIT,
Expand Down Expand Up @@ -1018,9 +1046,19 @@ static CURL *get_curl_handle(void)
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
#endif
#if LIBCURL_VERSION_NUM >= 0x073400
else if (starts_with(curl_http_proxy, "https"))
curl_easy_setopt(result,
CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);
else if (starts_with(curl_http_proxy, "https")) {
curl_easy_setopt(result, CURLOPT_PROXYTYPE, CURLPROXY_HTTPS);

if (http_proxy_ssl_cert != NULL)
curl_easy_setopt(result, CURLOPT_PROXY_SSLCERT, http_proxy_ssl_cert);

if (http_proxy_ssl_key != NULL)
curl_easy_setopt(result, CURLOPT_PROXY_SSLKEY, http_proxy_ssl_key);

if (http_proxy_ssl_keypasswd != NULL)
curl_easy_setopt(result, CURLOPT_PROXY_KEYPASSWD, http_proxy_ssl_keypasswd);

}
#endif
if (strstr(curl_http_proxy, "://"))
credential_from_url(&proxy_auth, curl_http_proxy);
Expand Down

0 comments on commit 652847d

Please sign in to comment.