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

Does anyone know how I could use LWP to work with https request. My problem is that I have a perl program that prints out a html file, and I have this other perl program that prints the weather into the html file. This program is also inside of the same server, that is I have to use https://nameofthescript to call it, code example
my $doc = get ("https://testing/weather.pl"); my @foot=$doc; $weather=join("",@foot);

Than from the main perl program I do the right substitution, but I know that LWP does not work with https, I need to find another way to do it. Any suggestions? Thanks!!!

Replies are listed 'Best First'.
Re: Using LWP w/ HTTPS
by dws (Chancellor) on Dec 27, 2002 at 18:17 UTC
    I know that LWP does not work with https ...

    If you're running ActiveState Perl on Win32, LWP needs an additional component to support https. Issue the following from a command prompt:   c:> ppm install Crypt-SSLeay and you'll have https support.

      Still having problems the program prints "500" Not working!!!!
        That doesn't mean there is a problem with LWP, there is probably a problem with your code. Check your servers error log and also make sure you are printing out correct headers.

        If you are still having trouble post your code here so that we can all have a look at it.

        Chris

        Lobster Aliens Are attacking the world!
Re: Using LWP w/ HTTPS
by Mr. Muskrat (Canon) on Dec 27, 2002 at 16:57 UTC

    Who told you that LWP does not work with https?

    from the LWP docs:
    HTTPS Requests
    HTTPS requests are HTTP requests over an encrypted network connection using the SSL protocol developed by Netscape. Everything about HTTP requests above also apply to HTTPS requests. In addition the library will add the headers ``Client-SSL-Cipher'', ``Client-SSL-Cert-Subject'' and ``Client-SSL-Cert-Issuer'' to the response. These headers denote the encryption method used and the name of the server owner.
    The request can contain the header ``If-SSL-Cert-Subject'' in order to make the request conditional on the content of the server certificate. If the certificate subject does not match, no request is sent to the server and an internally generated error response is returned. The value of the ``If-SSL-Cert-Subject'' header is interpreted as a Perl regular expression.

Re: Using LWP w/ HTTPS
by Mr. Muskrat (Canon) on Dec 27, 2002 at 17:05 UTC

    Okay, here goes a brief sample (almost entirely from the LWP docs) that has not been tested at all:

    #!/usr/bin/perl -w use strict; use LWP::UserAgent; my $ua = new LWP::UserAgent; my $req = HTTP::Request->new(GET => 'https://testing/weather.pl'); my $res = $ua->request($req); my $weather; if ($res->is_success) { $weather = $res->content; } else { die "download failed.\n"; } # the rest of your code goes here
Re: Using LWP w/ HTTPS
by IlyaM (Parson) on Dec 27, 2002 at 17:21 UTC