cURL / Mailing Lists / curl-library / Single Mail

curl-library

Getting error 'Proxy CONNECT aborted' when using CURLAUTH_ANY

From: Sudha <kssudha_at_gmail.com>
Date: Wed, 8 Apr 2009 23:00:13 +0530

Hello,

I have a piece of code for downloading a file from a given URL using a
proxy. I'm trying to make it work with both ISA proxy (using NTLM auth) and
Squid proxy (using Basic auth).
If I specify the proxy auth mechanism as CURLAUTH_NTLM and CURLAUTH_BASIC
respectively, both these proxies work fine. Since the code doesnt know which
kind of proxy it is talking to, I was looking for a generic solution. I used
CURLAUTH_ANY, and also tried CURLAUTH_BASIC | CURLAUTH_NTLM. With these two
options, ISA proxy works fine, but not the Squid proxy. Here is output with
using Squid proxy:

About to connect() to proxy 10.209.112.250 port 3128 (#0)
  Trying 10.209.112.250...
connected
Connected to 10.209.112.250 (10.209.112.250) port 3128 (#0)
Establish HTTP proxy tunnel to download.juniper.net:443
Server auth using Basic with user 'kssudha'
CONNECT download.juniper.net:443 HTTP/1.1
Host: download.juniper.net:443
Proxy-Connection: Keep-Alive
HTTP/1.0 407 Proxy Authentication Required
Server: Squid/2.4.STABLE6
Mime-Version: 1.0
Date: Wed, 08 Apr 2009 17:29:51 GMT
Content-Type: text/html
Content-Length: 951
Expires: Wed, 08 Apr 2009 17:29:51 GMT
X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
Proxy-Authenticate: Basic realm="Squid proxy-caching web server"
X-Cache: MISS from qasrvtest1
Proxy-Connection: keep-alive
Ignore 951 bytes of response-body
Establish HTTP proxy tunnel to download.juniper.net:443
Proxy auth using Basic with user 'qasrv1'
Server auth using Basic with user 'kssudha'
CONNECT download.juniper.net:443 HTTP/1.1
Host: download.juniper.net:443
Proxy-Authorization: Basic cWFzcnYxOm5lb3Rlcmlz
Proxy-Connection: Keep-Alive
Proxy CONNECT aborted
Closing connection #0download failed - rc=56 err='Proxy CONNECT aborted'

My code is as follows:
        CURL * curl = NULL;
        if ((curl = curl_easy_init()) == NULL) {
            printf ("Unable to init Curl\n"); }
        curl_easy_setopt(curl, CURLOPT_URL, "
https://download.juniper.net/software/av/uac/epupdate_hist.xml");
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curlError);
        curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
        curl_easy_setopt(curl, CURLOPT_PROXY, "10.209.112.250:3128");
        curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "<proxy user>:<proxy
password>");
        curl_easy_setopt(curl, CURLOPT_USERPWD, "<server username>:<server
password>");
        curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

        curl_easy_setopt(curl, CURLOPT_FILETIME, 1);
        curl_easy_setopt(curl, CURLOPT_TIMECONDITION,
CURL_TIMECOND_IFMODSINCE);
        curl_easy_setopt(curl, CURLOPT_CAINFO, 0);
        curl_easy_setopt(curl, CURLOPT_SSLVERSION, 3);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
        curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, curlSSLCallback);
        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
        int rc = curl_easy_perform(curl);
        if (curl != NULL) {
        curl_easy_cleanup(curl);
       }
If I just use CURLAUTH_BASIC, it works perfectly.
Received on 2009-04-08