@@ -155,6 +155,16 @@ static struct active_request_slot *active_queue_head;
155
155
156
156
static char * cached_accept_language ;
157
157
158
+ static char * http_ssl_backend ;
159
+
160
+ static int http_schannel_check_revoke = 1 ;
161
+ /*
162
+ * With the backend being set to `schannel`, setting sslCAinfo would override
163
+ * the Certificate Store in cURL v7.60.0 and later, which is not what we want
164
+ * by default.
165
+ */
166
+ static int http_schannel_use_ssl_cainfo ;
167
+
158
168
size_t fread_buffer (char * ptr , size_t eltsize , size_t nmemb , void * buffer_ )
159
169
{
160
170
size_t size = eltsize * nmemb ;
@@ -302,6 +312,22 @@ static int http_options(const char *var, const char *value, void *cb)
302
312
curl_ssl_try = git_config_bool (var , value );
303
313
return 0 ;
304
314
}
315
+ if (!strcmp ("http.sslbackend" , var )) {
316
+ free (http_ssl_backend );
317
+ http_ssl_backend = xstrdup_or_null (value );
318
+ return 0 ;
319
+ }
320
+
321
+ if (!strcmp ("http.schannelcheckrevoke" , var )) {
322
+ http_schannel_check_revoke = git_config_bool (var , value );
323
+ return 0 ;
324
+ }
325
+
326
+ if (!strcmp ("http.schannelusesslcainfo" , var )) {
327
+ http_schannel_use_ssl_cainfo = git_config_bool (var , value );
328
+ return 0 ;
329
+ }
330
+
305
331
if (!strcmp ("http.minsessions" , var )) {
306
332
min_curl_sessions = git_config_int (var , value );
307
333
#ifndef USE_CURL_MULTI
@@ -803,6 +829,16 @@ static CURL *get_curl_handle(void)
803
829
}
804
830
#endif
805
831
832
+ if (http_ssl_backend && !strcmp ("schannel" , http_ssl_backend ) &&
833
+ !http_schannel_check_revoke ) {
834
+ #if LIBCURL_VERSION_NUM >= 0x072c00
835
+ curl_easy_setopt (result , CURLOPT_SSL_OPTIONS , CURLSSLOPT_NO_REVOKE );
836
+ #else
837
+ warning ("CURLSSLOPT_NO_REVOKE not applied to curl SSL options because\n"
838
+ "your curl version is too old (>= 7.44.0)" );
839
+ #endif
840
+ }
841
+
806
842
if (http_proactive_auth )
807
843
init_curl_http_auth (result );
808
844
@@ -844,7 +880,13 @@ static CURL *get_curl_handle(void)
844
880
if (ssl_pinnedkey != NULL )
845
881
curl_easy_setopt (result , CURLOPT_PINNEDPUBLICKEY , ssl_pinnedkey );
846
882
#endif
847
- if (ssl_cainfo != NULL )
883
+ if (http_ssl_backend && !strcmp ("schannel" , http_ssl_backend ) &&
884
+ !http_schannel_use_ssl_cainfo ) {
885
+ curl_easy_setopt (result , CURLOPT_CAINFO , NULL );
886
+ #if LIBCURL_VERSION_NUM >= 0x073400
887
+ curl_easy_setopt (result , CURLOPT_PROXY_CAINFO , NULL );
888
+ #endif
889
+ } else if (ssl_cainfo != NULL )
848
890
curl_easy_setopt (result , CURLOPT_CAINFO , ssl_cainfo );
849
891
850
892
if (curl_low_speed_limit > 0 && curl_low_speed_time > 0 ) {
@@ -995,6 +1037,33 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
995
1037
git_config (urlmatch_config_entry , & config );
996
1038
free (normalized_url );
997
1039
1040
+ #if LIBCURL_VERSION_NUM >= 0x073800
1041
+ if (http_ssl_backend ) {
1042
+ const curl_ssl_backend * * backends ;
1043
+ struct strbuf buf = STRBUF_INIT ;
1044
+ int i ;
1045
+
1046
+ switch (curl_global_sslset (-1 , http_ssl_backend , & backends )) {
1047
+ case CURLSSLSET_UNKNOWN_BACKEND :
1048
+ strbuf_addf (& buf , _ ("Unsupported SSL backend '%s'. "
1049
+ "Supported SSL backends:" ),
1050
+ http_ssl_backend );
1051
+ for (i = 0 ; backends [i ]; i ++ )
1052
+ strbuf_addf (& buf , "\n\t%s" , backends [i ]-> name );
1053
+ die ("%s" , buf .buf );
1054
+ case CURLSSLSET_NO_BACKENDS :
1055
+ die (_ ("Could not set SSL backend to '%s': "
1056
+ "cURL was built without SSL backends" ),
1057
+ http_ssl_backend );
1058
+ case CURLSSLSET_TOO_LATE :
1059
+ die (_ ("Could not set SSL backend to '%s': already set" ),
1060
+ http_ssl_backend );
1061
+ case CURLSSLSET_OK :
1062
+ break ; /* Okay! */
1063
+ }
1064
+ }
1065
+ #endif
1066
+
998
1067
if (curl_global_init (CURL_GLOBAL_ALL ) != CURLE_OK )
999
1068
die ("curl_global_init failed" );
1000
1069
0 commit comments