Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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);

Comment on curl sends basic insted of ntlm
Download Code
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);

      hy

      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 http://cpansearch.perl.org/src/SZBALINT/WWW-Curl-4.15/Changes

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://942211]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (19)
As of 2014-10-30 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls