19
static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
20
static int trace_curl_data = 1;
21
static int trace_curl_redact = 1;
22
-#if LIBCURL_VERSION_NUM >= 0x070a08
22
long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
24
-#else
25
-long int git_curl_ipresolve;
26
-#endif
23
int active_requests;
24
int http_is_verbose;
25
ssize_t http_post_buffer = 16 * LARGE_PACKET_MAX;
26
31
-#if LIBCURL_VERSION_NUM >= 0x070a06
32
-#define LIBCURL_CAN_HANDLE_AUTH_ANY
33
-#endif
34
-
27
static int min_curl_sessions = 1;
28
static int curl_session_count;
29
#ifdef USE_CURL_MULTI
60
{ "tlsv1.3", CURL_SSLVERSION_TLSv1_3 },
61
#endif
62
};
71
-#if LIBCURL_VERSION_NUM >= 0x070903
63
static const char *ssl_key;
73
-#endif
74
-#if LIBCURL_VERSION_NUM >= 0x070908
64
static const char *ssl_capath;
76
-#endif
77
-#if LIBCURL_VERSION_NUM >= 0x071304
65
static const char *curl_no_proxy;
79
-#endif
66
#if LIBCURL_VERSION_NUM >= 0x072c00
67
static const char *ssl_pinnedkey;
68
#endif
87
{ "digest", CURLAUTH_DIGEST },
88
{ "negotiate", CURLAUTH_GSSNEGOTIATE },
89
{ "ntlm", CURLAUTH_NTLM },
104
-#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
90
{ "anyauth", CURLAUTH_ANY },
106
-#endif
91
/*
92
* CURLAUTH_DIGEST_IE has no corresponding command-line option in
93
* curl(1) and is not included in CURLAUTH_ANY, so we leave it out
127
128
static struct credential cert_auth = CREDENTIAL_INIT;
129
static int ssl_cert_password_required;
146
-#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
130
static unsigned long http_auth_methods = CURLAUTH_ANY;
131
static int http_auth_methods_restricted;
132
/* Modes for which empty_auth cannot actually help us. */
136
| CURLAUTH_DIGEST_IE
137
#endif
138
| CURLAUTH_DIGEST;
156
-#endif
139
140
static struct curl_slist *pragma_header;
141
static struct curl_slist *no_pragma_header;
219
if (slot->results != NULL) {
220
slot->results->curl_result = slot->curl_result;
221
slot->results->http_code = slot->http_code;
240
-#if LIBCURL_VERSION_NUM >= 0x070a08
222
curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL,
223
&slot->results->auth_avail);
243
-#else
244
- slot->results->auth_avail = 0;
245
-#endif
224
225
curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CONNECTCODE,
226
&slot->results->http_connectcode);
283
return git_config_string(&ssl_version, var, value);
284
if (!strcmp("http.sslcert", var))
285
return git_config_pathname(&ssl_cert, var, value);
308
-#if LIBCURL_VERSION_NUM >= 0x070903
286
if (!strcmp("http.sslkey", var))
287
return git_config_pathname(&ssl_key, var, value);
311
-#endif
312
-#if LIBCURL_VERSION_NUM >= 0x070908
288
if (!strcmp("http.sslcapath", var))
289
return git_config_pathname(&ssl_capath, var, value);
315
-#endif
290
if (!strcmp("http.sslcainfo", var))
291
return git_config_pathname(&ssl_cainfo, var, value);
292
if (!strcmp("http.sslcertpasswordprotected", var)) {
435
if (curl_empty_auth >= 0)
436
return curl_empty_auth;
437
464
-#ifndef LIBCURL_CAN_HANDLE_AUTH_ANY
465
- /*
466
- * Our libcurl is too old to do AUTH_ANY in the first place;
467
- * just default to turning the feature off.
468
- */
469
-#else
438
/*
439
* In the automatic case, kick in the empty-auth
440
* hack as long as we would potentially try some
447
if (http_auth_methods_restricted &&
448
(http_auth_methods & ~empty_auth_useless))
449
return 1;
482
-#endif
450
return 0;
451
}
452
519
520
var_override(&http_proxy_authmethod, getenv("GIT_HTTP_PROXY_AUTHMETHOD"));
521
555
-#if LIBCURL_VERSION_NUM >= 0x070a07 /* CURLOPT_PROXYAUTH and CURLAUTH_ANY */
522
if (http_proxy_authmethod) {
523
int i;
524
for (i = 0; i < ARRAY_SIZE(proxy_authmethods); i++) {
536
}
537
else
538
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
573
-#endif
539
}
540
541
static int has_cert_password(void)
844
}
845
#endif
846
882
-#if LIBCURL_VERSION_NUM >= 0x070907
847
curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
884
-#endif
885
-#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
848
curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
887
-#endif
849
850
#ifdef CURLGSSAPI_DELEGATION_FLAG
851
if (curl_deleg) {
901
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
902
if (has_cert_password())
903
curl_easy_setopt(result, CURLOPT_KEYPASSWD, cert_auth.password);
943
-#if LIBCURL_VERSION_NUM >= 0x070903
904
if (ssl_key != NULL)
905
curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
946
-#endif
947
-#if LIBCURL_VERSION_NUM >= 0x070908
906
if (ssl_capath != NULL)
907
curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
950
-#endif
908
#if LIBCURL_VERSION_NUM >= 0x072c00
909
if (ssl_pinnedkey != NULL)
910
curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
1137
curl_ssl_verify = 0;
1138
1139
set_from_env(&ssl_cert, "GIT_SSL_CERT");
1183
-#if LIBCURL_VERSION_NUM >= 0x070903
1140
set_from_env(&ssl_key, "GIT_SSL_KEY");
1185
-#endif
1186
-#if LIBCURL_VERSION_NUM >= 0x070908
1141
set_from_env(&ssl_capath, "GIT_SSL_CAPATH");
1188
-#endif
1142
set_from_env(&ssl_cainfo, "GIT_SSL_CAINFO");
1143
1144
set_from_env(&user_agent, "GIT_HTTP_USER_AGENT");
1320
else
1321
curl_easy_setopt(slot->curl, CURLOPT_FOLLOWLOCATION, 0);
1322
1370
-#if LIBCURL_VERSION_NUM >= 0x070a08
1323
curl_easy_setopt(slot->curl, CURLOPT_IPRESOLVE, git_curl_ipresolve);
1372
-#endif
1373
-#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
1324
curl_easy_setopt(slot->curl, CURLOPT_HTTPAUTH, http_auth_methods);
1375
-#endif
1325
if (http_auth.password || curl_empty_auth_enabled())
1326
init_curl_http_auth(slot->curl);
1327
1603
credential_reject(&http_auth);
1604
return HTTP_NOAUTH;
1605
} else {
1657
-#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
1606
http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
1607
if (results->auth_avail) {
1608
http_auth_methods &= results->auth_avail;
1609
http_auth_methods_restricted = 1;
1610
}
1663
-#endif
1611
return HTTP_REAUTH;
1612
}
1613
} else {