cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Error in proxy connection

From: Ranu Gontia <ranu_gontia_at_persistent.co.in>
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 www.google.co.in:80
> * Proxy auth using Basic with user 'username'

There's the proxy auth, but using Basic.

>> CONNECT www.google.co.in:80 HTTP/1.0

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_global_init(CURL_GLOBAL_DEFAULT);
CURL *curlhandle = curl_easy_init();
if (curlhandle)
{
                
        CStringA fileName;
        curl_easy_setopt(curlhandle,CURLOPT_URL, "ftp://myftp.server.com");
        curl_easy_setopt(curlhandle,CURLOPT_USERPWD,
"ftpusername:ftppasswd");
                        
        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_PROXYUSERPWD,
"username:password");
        
        curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION,&write_data);
        char headerfilename[FILENAME_MAX] = "head.out";
        FILE *headerfile = fopen(headerfilename,"w");
        if (headerfile == NULL) {
                curl_easy_cleanup(curlhandle);
                return retCode;
        }
        curl_easy_setopt(curlhandle, CURLOPT_WRITEHEADER ,headerfile);

        curl_easy_setopt(curlhandle, CURLOPT_VERBOSE ,1);
        retCode = curl_easy_perform(curlhandle);
        curl_easy_cleanup(curlhandle);
}
curl_global_cleanup();

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 myftp.server.com:21
* Server auth using Basic with user 'ftpusername'
> CONNECT myftp.server.com:21 HTTP/1.0
Host: myftp.server.com:21
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?

Thanks,
Ranu
Received on 2009-02-11