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

Inscrutable monks, I am trying to open an openssl connection to port 443 on a given host and GET the page. I do not wish to use expect. My code connects, but I see no html (doubtless I am doing something very wrong). Here's my pathetic code...
#!/usr/local/bin/perl -w use strict; my $url = "https//somehost.domain.com/"; my $url_port = "somehost.domain.com:443"; my @SSL; open( SSL,"| /usr/local/ssl/bin/openssl s_client -connect $url_port +"); print SSL "get $url\n"; close(SSL); foreach (@SSL) { print; }
We're doing this (as opposed to using LWP) because LWP is reporting errors and the java software devilopers want proof it's not because of reported problems they've read regarding LWP. Thank you in advance,

Replies are listed 'Best First'.
Re: Openssl & GET
by Aristotle (Chancellor) on Apr 28, 2003 at 20:20 UTC
    Why're you even using Perl for something a shell script will do in a pinch? Where do you expect the content in @SSL to come from if you never assign to it? Have you read the HTTP RFCs? Your request is completely malformed.
    echo -e "GET / HTTP/1.1\r\nHost: somehost.domain.com\r\n\r" \ | /usr/local/ssl/bin/openssl s_client -connect $url_port
    What kind of errors is LWP reporting? Can the Java guys show you their source for their information?

    Makeshifts last the longest.

      Tried the shell command, but all I get back is the openssl stuff--no html from the web page. The LWP reports 500 ("Internal Server Error"), but their (Java app) logs say they return a 200 code, BUT they do see some 2-6 minute latency in their app's DB access. And no, the Java guys haven't produced their bug reports. They're web devilopers--they tell you "it's out on the web, everyone knows it." Thanks again,
        I forgot you need to add -quiet for openssl(1) to actually print back the server's responses outside the SSL handshake, sorry.
        echo -e "GET / HTTP/1.1\r\nHost: somehost.domain.com\r\n\r" \ | /usr/local/ssl/bin/openssl s_client -quiet -connect somehost.domain. +com:443

        If the server is at all working, this should result in a HTTP response being echoed to you.

        One question: are you sure your LWP can do SSL transfers? You need to install extra modules for that purpose, it doesn't come with the ability out of the box. The LWP distribution has a README.SSL you might want to look into. To be honest your account of their "evidence" is not inspiring much respect for your Java crew's knowledge with me.

        Makeshifts last the longest.