Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

LWP and proxy authentication

by KarthikK (Sexton)
on Oct 29, 2007 at 16:02 UTC ( [id://647873]=perlquestion: print w/replies, xml ) Need Help??

KarthikK has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, I have been trying to access a secured website using LWP but in vain. below is my code

use strict; use LWP; use LWP::UserAgent; use LWP::Debug qw(+); my $URI = 'https://site.com/cc/login.do'; my $user = 'user'; my $pass = 'pwd'; # define user agent my $ua = LWP::UserAgent->new(); $ua->agent("USER/AGENT/IDENTIFICATION"); #set proxy $ua->proxy(['http','https'], 'http://nt_user:nt_pwd@proxy.domain.com:8 +080'); # make request my $request = HTTP::Request->new(GET => $URI); # authenticate $request->authorization_basic($user, $pass); # except response my $response = $ua->request($request); # get content of response my $content = $response->content(); # do whatever you need to do with the content here print $content;
I came to know from my server admin that the proxy request is sent as annonymous, eventhough I have specified my NT_user and password in the proxy url.

Any idea how to solve this problem?
I am able to access HTTP websites (ex: http://www.google.com)
Problem comes only when using HTTPS

the HTTPS site which i am accessing does not have a FORM authentication but Basic Authentication.

Its been more than 2 weeks still i could not find any solution for this.
>
best regards
Karthik

Replies are listed 'Best First'.
Re: LWP and proxy authentication
by almut (Canon) on Oct 29, 2007 at 19:18 UTC

    I suspect it could be the same old issue, which comes up from time to time...  I.e., in order to use a proxy with HTTPS, you have to set the environment variables

    $ENV{HTTPS_PROXY} = 'http://proxy.domain.com:8080'; $ENV{HTTPS_PROXY_USERNAME} = 'nt_user'; $ENV{HTTPS_PROXY_PASSWORD} = 'nt_pwd';

    instead of telling the LWP::UserAgent via

    $ua->proxy(['https'], ... );

    Those env variables are being interpreted by Crypt::SSLeay (used under the hood for HTTPS connections), which should then handle things correctly.  Good luck.

      Tried this and no luck :-( I have been struggling with this for last 3 weeks
Re: LWP and proxy authentication
by naikonta (Curate) on Oct 29, 2007 at 18:11 UTC
    Just a thought, how about changing authorization_basic with proxy_authorization_basic?

    Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 19:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found