cURL / Mailing Lists / curl-library / Single Mail


RE: Error in proxy connection

From: Ranu Gontia <>
Date: Wed, 11 Feb 2009 12:43:45 +0530

On Tuesday, February 10, 2009, Daniel Stenberg wrote:

I think you forgot to mention that you also used -p/--proxytunnel and used
proxy authentication! It will help if you shows us the same command line
that produced the HTTP dump you include...

> * Establish HTTP proxy tunnel to
> * Proxy auth using Basic with user 'username'

There's the proxy auth, but using Basic.


And here we see it trying a "proxy tunnel" to the remote site on port 80,
which probably isn't allowed by the proxy. I suggest you try just "regular"
use first.

> < HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires
> authoriza
> < Proxy-Authenticate: Negotiate
> < Proxy-Authenticate: Kerberos
> < Proxy-Authenticate: NTLM

And this shows you need digest auth with the proxy, which your command line
didn't use.

Actaul problem is wile I am using the library like this, to verify the same
I tried it with the cirl.exe ang got the same error using both.

CURL *curlhandle = curl_easy_init();
if (curlhandle)
        CStringA fileName;
        curl_easy_setopt(curlhandle,CURLOPT_URL, "");
        curl_easy_setopt(curlhandle, CURLOPT_HTTPPROXYTUNNEL, 0);
        curl_easy_setopt(curlhandle, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
        curl_easy_setopt(curlhandle, CURLOPT_PROXY_TRANSFER_MODE, 1);
        curl_easy_setopt(curlhandle, CURLOPT_PROXY, "myproxy:8080");
        curl_easy_setopt(curlhandle, CURLOPT_PROXYTYPE ,CURLPROXY_HTTP);

        curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION,&write_data);
        char headerfilename[FILENAME_MAX] = "head.out";
        FILE *headerfile = fopen(headerfilename,"w");
        if (headerfile == NULL) {
                return retCode;
        curl_easy_setopt(curlhandle, CURLOPT_WRITEHEADER ,headerfile);

        curl_easy_setopt(curlhandle, CURLOPT_VERBOSE ,1);
        retCode = curl_easy_perform(curlhandle);

If I specify that I am using proxy tunnel
i.e. curl_easy_setopt(curlhandle, CURLOPT_HTTPPROXYTUNNEL, 1);
then following error comes -:

* About to connect() to proxy myproxy port 8080 (#0)
* Trying myproxy... * connected
* Connected to myproxy (x.x.x.x) port 8080 (#0)
* Establish HTTP proxy tunnel to
* Server auth using Basic with user 'ftpusername'
Proxy-Connection: Keep-Alive

< HTTP/1.1 502 Proxy Error ( The specified Secure Sockets Layer (SSL) port
is no
t allowed. ISA Server is not configured to allow SSL requests from this
port. Mo
st Web browsers use port 443 for SSL requests. )
The body is <body.out>
< Via: 1.1 MYPROXY2
< Connection: close
< Proxy-Connection: close
< Pragma: no-cache
< Cache-Control: no-cache
< Content-Type: text/html
< Content-Length: 776
* Received HTTP code 502 from proxy after CONNECT
* Closing connection #0
* Failure when receiving data from the peer

How to resolve this problem?

Received on 2009-02-11