Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

curl sends basic insted of ntlm

by dsx (Novice)
on Dec 07, 2011 at 10:51 UTC ( #942211=perlquestion: print w/replies, xml ) Need Help??
dsx has asked for the wisdom of the Perl Monks concerning the following question:

hello guys

i want download a file from a IIS webserver which requires ntlm authentication. but WWW::Curl::Easy sends a basic-authentication-header. what could be the problem?

#!/usr/bin/perl open(TMPF, ">", "tempfile"); print "User: "; chomp($user = <STDIN>); if (system("stty -echo") == 0){ print "Password: "; chomp($pw = <STDIN>); }else{ print "stty -echo failed"; exit 1; } system("stty echo"); use WWW::Curl::Easy; my $curl = WWW::Curl::Easy->new; $curl->setopt(CURLOPT_URL,'http://ugly_iis/securedoument.txt'); $curl->setopt(CURLOPT_FOLLOWLOCATION,1); $curl->setopt(CURLOPT_UNRESTRICTED_AUTH,1); $curl->setopt(CURLOPT_HTTPAUTH,CURLAUTH_NTLM); $curl->setopt(CURLOPT_USERPWD,$user . ':' . $pw); $curl->setopt(CURLOPT_FILE,TMPF); my $retcode = $curl->perform; close(TMPF);

Replies are listed 'Best First'.
Re: curl sends basic insted of ntlm
by Anonymous Monk on Dec 07, 2011 at 11:09 UTC

    Ask curl  $curl->setopt(CURLOPT_VERBOSE,1);


      the verbose mode gave me the following error

      gss_init_sec_context() failed: : Credentials cache file '/tmp/krb5cc_1000' not found< WWW-Authenticate: Negotiate

      seems to be a bug of libcurl if curl is built with NSS insted of OpenSSL. but curl --version gives me

      curl --version curl 7.21.0 (i486-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2 +.3.4 libidn/1.15 libssh2/1.2.6 x Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 po +p3s rtsp scp sftp smtp smtps telnet tftp Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

      how can i find out wich version of libcurl perl does use?

        the problem was a bug in the version 4.12 of the module WWW::Curl which is used in the debian package libwww-perl-curl. the bug is fixed in the recent version of WWW::Curl

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://942211]
Approved by McDarren
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-08-18 14:51 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (303 votes). Check out past polls.