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

Okay....here's the deal

I've installed ActiveState's 5.8 version of Perl on Win2k

I ran 'ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd' (as recommended on Google Groups)

I copied code straight out of lwpcook on cpan for loading a webpage using HTTP and HTTPS

if my target is 'http://blah', then it loads just fine in a browser - no hassles, exactly what I expected (which is: URL is my perl script, content is the webpage specified in the script)

If I run the self-same script from a commandline, it also does what is expected (prints to screen the HTML that the target URL contains)

If I change the target to 'https://blah' then the browser hangs - processing, processing, doesn't stop

If I run the self-same script from a commandline, then it works as it did above - printing the HTML from the target URL

any ideas? did i miss a flag somewhere?

any insight or direction would be appreciated

code follows:
#!c:\perl\bin\perl.exe
use LWP::UserAgent;

$bup = 'http://ias4/error_403.html';
my $ua = LWP::UserAgent->new;
print "Content-type: text/html\r\n\r\n";
print $bup."\n";
my $req = HTTP::Request->new(GET => $bup);
$req->header('Accept' => 'text/html');

# send request
my $res = $ua->request($req);

# check the outcome
if ($res->is_success)
{	print $res->content;	}
else 
{	print "Error: " . $res->status_line . "\n";	}

Replies are listed 'Best First'.
Re: LWP, Crypt-SSLeay, and CLI vs. WWW
by hardburn (Abbot) on Feb 24, 2004 at 17:53 UTC

    This probably isn't a Perl issue, but just how your web server is configured. Many web servers only take SSL requests on a specific virtual host (like "https://secure.example.com"). You'll need to feed your browser/Perl code the correct URI for the SSL site.

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

      well....one of the things I tried before I posted was to see if the machine the .pl lived on could see both web addr (http, https) in a web browser - could both times

      is there something i can check after that?

      specifically, the address i'm trying to go to is
      http(s)://ias4/error_403.html

      with http, works through browser and CLI
      with https, works only through CLI
      the machine where the .pl lives can open up both http://... and https://... in a browser

      maybe I'm just being obtuse (entirely possible) but I can't get past thinking that it's something in how I'm making the call in the .pl
        Whenever someone says "it works fine from the command line but it doesn't work as CGI..." it makes me think of users' permissions. The user executing CGI scripts is oftentimes "apache" or "nobody". When you run the same script from the command line, you're logged in as a user with rights and permissions that are usually quite different from apache/nobody.

        Also, I'm guessing you're running the CLI script with the same account you ran the PPM to install Crypt::SSLeay which is different than the account your web browser uses to exectute the script as a CGI.

        It may or may not help, but it's something to think about.

        Cheers,

        Brent
        -- Yeah, I'm a Delt.

Re: LWP, Crypt-SSLeay, and CLI vs. WWW
by freddo411 (Chaplain) on Feb 24, 2004 at 17:59 UTC
    I concur with hardburn. Sounds like your web server isn't serving up your CGI as your expect (at least on the https side).

    Suggestion: Put a gif file in place on the server and view it with http and https and see how that works.

    --Fred

    -------------------------------------
    Nothing is too wonderful to be true
    -- Michael Faraday

      I had a project where the page resided in /home/timesheets/public_html and was mapped to www.thedomain.edu/timesheets and I had to end up adding apache and the login id of the associated directory in this case into a user group and granting 7 group permissions to be able to upload files via a CGI script.

      Grygonos