Click here to get back home

Using HTTPS with LWP::UserAgent = Bad Service

 HomeNewsGroups | Search

comp.lang.perl.modules - Discussion about PERL modules 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Using HTTPS with LWP::UserAgent = Bad Service Richard Lawrence 03-30-2005
Posted by Richard Lawrence on March 30, 2005, 6:45 am
Please log in for more thread options


Hi all,

I'm trying to access https://www.nodeworks.com/ through a proxy which
requires a proxy username and password. The code I have is as follows:

#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use Data::Dumper qw(Dumper);
# If they provide an argument, connect to https else http
my $url = "http://www.nodeworks.com";
$url = "https://www.nodeworks.com" if ($ARGV[0]);
print "Going to get $urln";
my $ua = new LWP::UserAgent;
# According to Crypt::SSLeay:
# "Use of the HTTPS_PROXY environment variable in this way is
show/hide quoted text
# method will likely override or break the Crypt::SSLeay support,
# so do not mix the two."
show/hide quoted text
if ($url =~ /^https/i)
{
print "Using HTTPS proxy $ENVn";
}
else
{
show/hide quoted text
print "Using HTTP proxy $ENVn";
}
show/hide quoted text
my $req = new HTTP::Request('HEAD', $url);
show/hide quoted text
print "Result is:n";
print Dumper($res);

My environment variable for http_proxy is set up like so:

http_proxy=http://richard:mypassword@10.10.200.44:8080/
HTTP_PROXY=http://richard:mypassword@10.10.200.44:8080/
export ...all of the above...

and running the code above with no arguments produces the desired
result.

However, if I try the code above with an argument (so it trys https)
with the following environment variables:

https_proxy=http://richard:mypassword@10.10.200.44:8080/
HTTPS_PROXY=http://richard:mypassword@10.10.200.44:8080/
export ...all of the above...

or even:

https_proxy=http://10.10.200.44:8080/
HTTPS_PROXY=http://10.10.200.44:8080/
https_proxy_username=richard
HTTPS_PROXY_USERNAME=richard
https_proxy_password=mypassword
HTTPS_PROXY_PASSWORD=mypassword
export ...all of the above...

then I always get the following error:

$VAR1 = bless( {
show/hide quoted text
'8080/')',
show/hide quoted text
}, 'HTTP::Headers' ),
show/hide quoted text
'8080/')',
show/hide quoted text
'URI::https' ),
show/hide quoted text
}, 'HTTP::Headers' ),
show/hide quoted text
}, 'HTTP::Request' )
}, 'HTTP::Response' );

Can anyone offer any suggestions?

Many thanks,

Richard



Posted by Ilmari Karonen on March 31, 2005, 1:42 am
Please log in for more thread options


["Followup-To:" set to comp.lang.perl.misc.]

show/hide quoted text

I don't have a proxy that would require a username and a password, but
I've tested your code as far as I've can. As far as I can tell, your
code works just as it should -- the problem is elsewhere.


show/hide quoted text

Just so you know, you can get a much cleaner dump of the response by
show/hide quoted text

show/hide quoted text


show/hide quoted text

You don't need this; the uppercase version is the proper one.

show/hide quoted text

It appears that Crypt::SSLeay doesn't support this syntax, and will
fail with an error similar to what you report. So this is likely to
be at least a part of your problem.


show/hide quoted text

This, however, seems to work just fine. Of course, I can't really
test if the authentication works or not, but at least there is no
error. You're reporting that you get the same "Bad service" error
each time, but I'd really suggest you try it one more time, and make
sure $ENV really contains what you think it does. You
could add something like this to your code to dump the relevant
environment variables:

/^HTTPS?_PROXY/ and print "$_=$ENVn" for sort keys %ENV;


Hope this helps.

--
Ilmari Karonen
To reply by e-mail, please replace ".invalid" with ".net" in address.


Similar ThreadsPosted
LWP::UserAgent + HTTPS + threads ==> segmentation fault November 11, 2004, 9:57 pm
Proxy method does not work using LWP::UserAgent for HTTPS request September 9, 2008, 6:53 am
How to get service logon user January 31, 2006, 9:36 am
Win32::Service Determining which are set to start automatically July 12, 2004, 10:14 am
SOAP::Lite with large web service payloads January 10, 2006, 12:42 pm
SOAP::Lite - is Barnes and Noble web service still active? July 6, 2007, 9:36 am
mod_perl, LWP and HTTPS January 11, 2005, 7:35 pm
LWP, https and a proxy February 22, 2005, 7:43 am
HTTPS URLs monitoring October 10, 2008, 2:20 pm
HTTPS Posts seem to be lacking the content (libwww-perl) January 3, 2006, 6:56 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy