| 1117 | } |
| 1118 | |
| 1119 | static CURL *get_curl_handle(void) |
| 1120 | { |
| 1121 | CURL *result = curl_easy_init(); |
| 1122 | |
| 1123 | if (!result) |
| 1124 | die("curl_easy_init failed"); |
| 1125 | |
| 1126 | if (!curl_ssl_verify) { |
| 1127 | curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0L); |
| 1128 | curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 0L); |
| 1129 | } else { |
| 1130 | /* Verify authenticity of the peer's certificate */ |
| 1131 | curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 1L); |
| 1132 | /* The name in the cert must match whom we tried to connect */ |
| 1133 | curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2L); |
| 1134 | } |
| 1135 | |
| 1136 | if (curl_http_version) { |
| 1137 | long opt; |
| 1138 | if (!get_curl_http_version_opt(curl_http_version, &opt)) { |
| 1139 | /* Set request use http version */ |
| 1140 | curl_easy_setopt(result, CURLOPT_HTTP_VERSION, opt); |
| 1141 | } |
| 1142 | } |
| 1143 | |
| 1144 | curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); |
| 1145 | curl_easy_setopt(result, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
| 1146 | |
| 1147 | #ifdef CURLGSSAPI_DELEGATION_FLAG |
| 1148 | if (curl_deleg) { |
| 1149 | int i; |
| 1150 | for (i = 0; i < ARRAY_SIZE(curl_deleg_levels); i++) { |
| 1151 | if (!strcmp(curl_deleg, curl_deleg_levels[i].name)) { |
| 1152 | curl_easy_setopt(result, CURLOPT_GSSAPI_DELEGATION, |
| 1153 | curl_deleg_levels[i].curl_deleg_param); |
| 1154 | break; |
| 1155 | } |
| 1156 | } |
| 1157 | if (i == ARRAY_SIZE(curl_deleg_levels)) |
| 1158 | warning("Unknown delegation method '%s': using default", |
| 1159 | curl_deleg); |
| 1160 | } |
| 1161 | #endif |
| 1162 | |
| 1163 | if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) && |
| 1164 | !http_schannel_check_revoke) { |
| 1165 | curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, (long)CURLSSLOPT_NO_REVOKE); |
| 1166 | } |
| 1167 | |
| 1168 | if (http_proactive_auth != PROACTIVE_AUTH_NONE) |
| 1169 | init_curl_http_auth(result); |
| 1170 | |
| 1171 | if (getenv("GIT_SSL_VERSION")) |
| 1172 | ssl_version = getenv("GIT_SSL_VERSION"); |
| 1173 | if (ssl_version && *ssl_version) { |
| 1174 | int i; |
| 1175 | for (i = 0; i < ARRAY_SIZE(sslversions); i++) { |
| 1176 | if (!strcmp(ssl_version, sslversions[i].name)) { |
no test coverage detected