Add verbose HTTPS proxy message for fail on CURLE_SSL_CACERT #1258

jay opened this Issue Feb 11, 2017 · 2 comments


None yet

3 participants

jay commented Feb 11, 2017

I think we should add some message to the tool's verbose text if an HTTPS proxy is in use and CURLE_SSL_CACERT. For example append a line mentioning --proxy-insecure and --proxy-cacert if the user specified an HTTPS proxy:

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
HTTPS proxy has similar options --proxy-cacert and --proxy-insecure.

and in code:

diff --git a/src/tool_operate.c b/src/tool_operate.c
index 94ae74d..8f89f04 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1681,8 +1681,13 @@ static CURLcode operate_do(struct GlobalConfig *global,
           fprintf(global->errors, "curl: (%d) %s\n", result, (errorbuffer[0]) ?
                   errorbuffer : curl_easy_strerror(result));
           if(result == CURLE_SSL_CACERT)
-            fprintf(global->errors, "%s%s",
+            fprintf(global->errors, "%s%s%s",
+                    ((config->proxy &&
+                      curl_strnequal(config->proxy, "https://", 8)) ?
+                     "HTTPS proxy has similar options --proxy-cacert "
+                     "and --proxy-insecure.\n" :
+                     ""));
         /* Fall through comment to 'quit_urls' label */

/cc @rousskov


@jay, you should not ask me but IMHO, ideally, curl should detect/relay which certificate (origin or proxy) failed verification and adjust the error message accordingly. Reaching that ideal is probably difficult, and your change is probably sufficient to help most users.

bagder commented Feb 11, 2017

Right, we don't return enough accuracy in the return code for a user to tell if it was a server or proxy that failed the certificate verification - that might be a subject for a separate issue. So until we have that, I'm 👍 on this suggestion.

@jay jay added a commit that closed this issue Feb 11, 2017
@jay jay tool_operate: Show HTTPS-Proxy options on CURLE_SSL_CACERT
When CURLE_SSL_CACERT occurs the tool shows a lengthy error message to
the user explaining possible solutions such as --cacert and --insecure.

This change appends to that message similar options --proxy-cacert and
--proxy-insecure when there's a specified HTTPS proxy.

Closes #1258
@jay jay closed this in e1187c4 Feb 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment