develooper Front page | perl.libwww | Postings from February 2003

RE: how to fetch https pages

Thread Previous | Thread Next
From:
Wenjie Wang
Date:
February 11, 2003 15:47
Subject:
RE: how to fetch https pages
Message ID:
JDEPIIKPBKGBMAJPGMKPEEHJDHAA.williamw@aurema.com
Hi Lance,

It all sounds familiar :-)  Actually, I've sort of experiencing the same
problem before.  After finds out SSL support is needed and have it
installed, It'll be an easy task.  But it's a bit tricky if you're behind a
fire wall. It'll be even trickier if you're on a dialup connection behind a
fire wall.  As a matter of fact, I'm still struggling with it.

The following code snip works fine to fetch page from SSL site when Using
LWP v5.64 under Perl v5.006001 MSWin32.  btw, I've also have OpenSSL
installed on c:\openssl.

---------------------------------8<------------------------------
# PROXY SUPPORT for SSLeay module
# It'll be unhappy if using
# $myUserAgent->proxy (http => $ENV{HTTPS_PROXY}) at the same time;
$ENV{HTTPS_PROXY} = 'http://your.proxy:port';
$ENV{HTTP_PROXY} = 'http://your.proxy:port';

# No need to keep_alive if you're not going to keep the session alive
$myUserAgent = LWP::UserAgent->new(keep_alive => 2);

#optional
$myUserAgent->agent($myUserAgent_name);

# optional, but you are most likely need a cookie jar
$myUserAgent->cookie_jar({});  # turn on in-memory cookies.

my $req = new HTTP::Request 'POST','https://www.yourSSLServer.com/';

# It depends on the contents your server are expecting
$req->content_type('application/x-www-form-urlencoded');
$req->content('LoginName=xxx&Password=xxx');

# submit your request
my $myResponse = $myUserAgent->request($req);

die "complain it before leaving...\n" if ($myResponse->is_error);
---------------------------------8<------------------------------

The above code works fine, except when I use it from my home pc which is
connected to my office via dialup.  It always complains "unknown host" for
some servers which happen running IIS.  I'm still struggling with the
problem and still haven't got a clue what's the problem.


Regards.
WWang
>-----Original Message-----
>From: Lance [mailto:lancestuff27@hotmail.com]
>Sent: Tuesday, 11 February 2003 9:21 PM
>To: libwww@perl.org
>Subject: Re: how to fetch https pages
>
>
>
>"Lance" <lancestuff27@hotmail.com> wrote in message
>news:20030211084530.50400.qmail@onion.perl.org...
>> What modules have to be installed for LWP::UserAgent to read SSL
>pages?  I
>> have been trying to install Crypt-SSLeay, but I keep getting the message:
>> 'Error: no suitable installation target found for package Crypt-SSLeay.'
>>
>> I am using ActiveState 5.6.1-build 633 on win XP
>>
>> I have been trying to use ppm3 to do the install, is there a way
>to get it
>> to list dependances of modules you are trying to install?  The docs say
>that
>> it will automatically install dependant modules, but it does not seem to
>be
>> working for me!
>>
>>
>
>
>OK, I finally found out why Crypt-SSLeay won't install.  It is a
>Solaris-only module!  I used 'describe Crypt-SSLeay' in ppm3 to find this
>out.  So the next question is:  How can I use my perl script to read https
>pages?  I keep getting a 501 http error code - protocol not available.
>
>The LWP docs say to use Crypt-SSLeay, btw.  But no alternatives.
>
>
>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About