@@ -86,6 +86,13 @@ static long curl_low_speed_time = -1;
86
86
static int curl_ftp_no_epsv ;
87
87
static const char * curl_http_proxy ;
88
88
static const char * http_proxy_authmethod ;
89
+
90
+ static const char * http_proxy_ssl_cert ;
91
+ static const char * http_proxy_ssl_key ;
92
+ static const char * http_proxy_ssl_ca_info ;
93
+ static struct credential proxy_cert_auth = CREDENTIAL_INIT ;
94
+ static int proxy_ssl_cert_password_required ;
95
+
89
96
static struct {
90
97
const char * name ;
91
98
long curlauth_param ;
@@ -365,6 +372,20 @@ static int http_options(const char *var, const char *value, void *cb)
365
372
if (!strcmp ("http.proxyauthmethod" , var ))
366
373
return git_config_string (& http_proxy_authmethod , var , value );
367
374
375
+ if (!strcmp ("http.proxysslcert" , var ))
376
+ return git_config_string (& http_proxy_ssl_cert , var , value );
377
+
378
+ if (!strcmp ("http.proxysslkey" , var ))
379
+ return git_config_string (& http_proxy_ssl_key , var , value );
380
+
381
+ if (!strcmp ("http.proxysslcainfo" , var ))
382
+ return git_config_string (& http_proxy_ssl_ca_info , var , value );
383
+
384
+ if (!strcmp ("http.proxysslcertpasswordprotected" , var )) {
385
+ proxy_ssl_cert_password_required = git_config_bool (var , value );
386
+ return 0 ;
387
+ }
388
+
368
389
if (!strcmp ("http.cookiefile" , var ))
369
390
return git_config_pathname (& curl_cookie_file , var , value );
370
391
if (!strcmp ("http.savecookies" , var )) {
@@ -565,6 +586,21 @@ static int has_cert_password(void)
565
586
return 1 ;
566
587
}
567
588
589
+ #if LIBCURL_VERSION_NUM >= 0x073400
590
+ static int has_proxy_cert_password (void )
591
+ {
592
+ if (http_proxy_ssl_cert == NULL || proxy_ssl_cert_password_required != 1 )
593
+ return 0 ;
594
+ if (!proxy_cert_auth .password ) {
595
+ proxy_cert_auth .protocol = xstrdup ("cert" );
596
+ proxy_cert_auth .username = xstrdup ("" );
597
+ proxy_cert_auth .path = xstrdup (http_proxy_ssl_cert );
598
+ credential_fill (& proxy_cert_auth );
599
+ }
600
+ return 1 ;
601
+ }
602
+ #endif
603
+
568
604
#if LIBCURL_VERSION_NUM >= 0x071900
569
605
static void set_curl_keepalive (CURL * c )
570
606
{
@@ -924,8 +960,14 @@ static CURL *get_curl_handle(void)
924
960
#if LIBCURL_VERSION_NUM >= 0x073400
925
961
curl_easy_setopt (result , CURLOPT_PROXY_CAINFO , NULL );
926
962
#endif
927
- } else if (ssl_cainfo != NULL )
928
- curl_easy_setopt (result , CURLOPT_CAINFO , ssl_cainfo );
963
+ } else if (ssl_cainfo != NULL || http_proxy_ssl_ca_info != NULL ) {
964
+ if (ssl_cainfo != NULL )
965
+ curl_easy_setopt (result , CURLOPT_CAINFO , ssl_cainfo );
966
+ #if LIBCURL_VERSION_NUM >= 0x073400
967
+ if (http_proxy_ssl_ca_info != NULL )
968
+ curl_easy_setopt (result , CURLOPT_PROXY_CAINFO , http_proxy_ssl_ca_info );
969
+ #endif
970
+ }
929
971
930
972
if (curl_low_speed_limit > 0 && curl_low_speed_time > 0 ) {
931
973
curl_easy_setopt (result , CURLOPT_LOW_SPEED_LIMIT ,
@@ -1018,9 +1060,18 @@ static CURL *get_curl_handle(void)
1018
1060
CURLOPT_PROXYTYPE , CURLPROXY_SOCKS4 );
1019
1061
#endif
1020
1062
#if LIBCURL_VERSION_NUM >= 0x073400
1021
- else if (starts_with (curl_http_proxy , "https "))
1022
- curl_easy_setopt (result ,
1023
- CURLOPT_PROXYTYPE , CURLPROXY_HTTPS );
1063
+ else if (starts_with (curl_http_proxy , "https ")) {
1064
+ curl_easy_setopt (result , CURLOPT_PROXYTYPE , CURLPROXY_HTTPS );
1065
+
1066
+ if (http_proxy_ssl_cert )
1067
+ curl_easy_setopt (result , CURLOPT_PROXY_SSLCERT , http_proxy_ssl_cert );
1068
+
1069
+ if (http_proxy_ssl_key )
1070
+ curl_easy_setopt (result , CURLOPT_PROXY_SSLKEY , http_proxy_ssl_key );
1071
+
1072
+ if (has_proxy_cert_password ())
1073
+ curl_easy_setopt (result , CURLOPT_PROXY_KEYPASSWD , proxy_cert_auth .password );
1074
+ }
1024
1075
#endif
1025
1076
if (strstr (curl_http_proxy , "://" ))
1026
1077
credential_from_url (& proxy_auth , curl_http_proxy );
@@ -1160,6 +1211,13 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
1160
1211
max_requests = DEFAULT_MAX_REQUESTS ;
1161
1212
#endif
1162
1213
1214
+ set_from_env (& http_proxy_ssl_cert , "GIT_PROXY_SSL_CERT" );
1215
+ set_from_env (& http_proxy_ssl_key , "GIT_PROXY_SSL_KEY" );
1216
+ set_from_env (& http_proxy_ssl_ca_info , "GIT_PROXY_SSL_CAINFO" );
1217
+
1218
+ if (getenv ("GIT_PROXY_SSL_CERT_PASSWORD_PROTECTED" ))
1219
+ proxy_ssl_cert_password_required = 1 ;
1220
+
1163
1221
if (getenv ("GIT_CURL_FTP_NO_EPSV" ))
1164
1222
curl_ftp_no_epsv = 1 ;
1165
1223
@@ -1230,6 +1288,12 @@ void http_cleanup(void)
1230
1288
}
1231
1289
ssl_cert_password_required = 0 ;
1232
1290
1291
+ if (proxy_cert_auth .password != NULL ) {
1292
+ memset (proxy_cert_auth .password , 0 , strlen (proxy_cert_auth .password ));
1293
+ FREE_AND_NULL (proxy_cert_auth .password );
1294
+ }
1295
+ proxy_ssl_cert_password_required = 0 ;
1296
+
1233
1297
FREE_AND_NULL (cached_accept_language );
1234
1298
}
1235
1299
0 commit comments