Skip to content

Commit b259646

Browse files
committed
url: Improve CURLOPT_PROXY_CAPATH error handling
- Change CURLOPT_PROXY_CAPATH to return CURLE_NOT_BUILT_IN if the option is not supported, which is the same as what we already do for CURLOPT_CAPATH. - Change the curl tool to handle CURLOPT_PROXY_CAPATH error CURLE_NOT_BUILT_IN as a warning instead of as an error, which is the same as what we already do for CURLOPT_CAPATH. - Fix CAPATH docs to show that CURLE_NOT_BUILT_IN is returned when the respective CAPATH option is not supported by the SSL library. Ref: #1257
1 parent 0e8d3e8 commit b259646

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

docs/libcurl/opts/CURLOPT_CAPATH.3

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ TODO
4949
This option is supported by the OpenSSL, GnuTLS and PolarSSL backends. The NSS
5050
backend provides the option only for backward compatibility.
5151
.SH RETURN VALUE
52-
Returns CURLE_OK if TLS enabled, and CURLE_UNKNOWN_OPTION if not, or
53-
CURLE_OUT_OF_MEMORY if there was insufficient heap space.
52+
CURLE_OK if supported; or an error such as:
53+
54+
CURLE_NOT_BUILT_IN - Not supported by the SSL backend
55+
56+
CURLE_UNKNOWN_OPTION
57+
58+
CURLE_OUT_OF_MEMORY
5459
.SH "SEE ALSO"
5560
.BR CURLOPT_CAINFO "(3), "
5661
.BR CURLOPT_STDERR "(3), " CURLOPT_DEBUGFUNCTION "(3), "

docs/libcurl/opts/CURLOPT_PROXY_CAPATH.3

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ Added in 7.52.0
4848
This option is supported by the OpenSSL, GnuTLS and PolarSSL backends. The NSS
4949
backend provides the option only for backward compatibility.
5050
.SH RETURN VALUE
51-
Returns CURLE_OK if TLS enabled, and CURLE_UNKNOWN_OPTION if not, or
52-
CURLE_OUT_OF_MEMORY if there was insufficient heap space.
51+
CURLE_OK if supported; or an error such as:
52+
53+
CURLE_NOT_BUILT_IN - Not supported by the SSL backend
54+
55+
CURLE_UNKNOWN_OPTION
56+
57+
CURLE_OUT_OF_MEMORY
5358
.SH "SEE ALSO"
5459
.BR CURLOPT_CAINFO "(3), "
5560
.BR CURLOPT_STDERR "(3), " CURLOPT_DEBUGFUNCTION "(3), "

lib/url.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,9 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
583583
if(result)
584584
return result;
585585

586-
result = setstropt(&set->str[STRING_SSL_CAPATH_PROXY],
587-
(char *) CURL_CA_PATH);
586+
result = setstropt(&set->str[STRING_SSL_CAPATH_PROXY], CURL_CA_PATH);
587+
if(result)
588+
return result;
588589
#endif
589590

590591
set->wildcardmatch = FALSE;
@@ -2225,8 +2226,12 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
22252226
/* This does not work on windows. */
22262227
result = setstropt(&data->set.str[STRING_SSL_CAPATH_ORIG],
22272228
va_arg(param, char *));
2229+
#else
2230+
result = CURLE_NOT_BUILT_IN;
2231+
#endif
22282232
break;
22292233
case CURLOPT_PROXY_CAPATH:
2234+
#ifdef have_curlssl_ca_path /* not supported by all backends */
22302235
/*
22312236
* Set CA path info for SSL connection proxy. Specify directory name of the
22322237
* CA certificates which have been prepared using openssl c_rehash utility.

src/tool_operate.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ static CURLcode operate_do(struct GlobalConfig *global,
10141014
my_setopt_str(curl, CURLOPT_CAINFO, config->cacert);
10151015
if(config->proxy_cacert)
10161016
my_setopt_str(curl, CURLOPT_PROXY_CAINFO, config->proxy_cacert);
1017+
10171018
if(config->capath) {
10181019
result = res_setopt_str(curl, CURLOPT_CAPATH, config->capath);
10191020
if(result == CURLE_NOT_BUILT_IN) {
@@ -1024,10 +1025,22 @@ static CURLcode operate_do(struct GlobalConfig *global,
10241025
else if(result)
10251026
goto show_error;
10261027
}
1027-
if(config->proxy_capath)
1028-
my_setopt_str(curl, CURLOPT_PROXY_CAPATH, config->proxy_capath);
1029-
else if(config->capath) /* CURLOPT_PROXY_CAPATH default is capath */
1030-
my_setopt_str(curl, CURLOPT_PROXY_CAPATH, config->capath);
1028+
/* For the time being if --proxy-capath is not set then we use the
1029+
--capath value for it, if any. See #1257 */
1030+
if(config->proxy_capath || config->capath) {
1031+
result = res_setopt_str(curl, CURLOPT_PROXY_CAPATH,
1032+
(config->proxy_capath ?
1033+
config->proxy_capath :
1034+
config->capath));
1035+
if(result == CURLE_NOT_BUILT_IN) {
1036+
if(config->proxy_capath) {
1037+
warnf(config->global,
1038+
"ignoring --proxy-capath, not supported by libcurl\n");
1039+
}
1040+
}
1041+
else if(result)
1042+
goto show_error;
1043+
}
10311044

10321045
if(config->crlfile)
10331046
my_setopt_str(curl, CURLOPT_CRLFILE, config->crlfile);

0 commit comments

Comments
 (0)