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

Hi Monks,

In my current project, I have to interact with a https site. They have provided digital certificate in both ‘.pfx’ and ‘.pem’ format. I tried to connect using ‘Crypt::SSLeay’ module and getting the following response.


500 Connect failed: connect: Connection refused Connection refused


I tested with setting both HTTPS_CERT_FILE and HTTPS_PKCS12_FILE environment variables. The following is the code used for testing the same.
#!/usr/bin/perl use LWP; use Data::Dumper; $ENV{HTTPS_CERT_FILE} = '/tmp/34556_cert.pem'; # $ENV{HTTPS_PKCS12_FILE} = '/tmp/34556_pkcs.pfx'; # $ENV{HTTPS_PKCS12_PASSWORD} = '34556'; my $url = 'https://sitename.com’; # Yes, HTTPS! my $browser = LWP::UserAgent->new; my $response = $browser->get($url); die "Error at $url\n ", $response->status_line, "\n Aborting" unless $response->is_success; print "Whee, it worked! I got that ", $response->content_type, " document!\n";

Any ideas will be greatly appreciated.

Replies are listed 'Best First'.
Re: Handling SSL digital certificate using LWP
by zentara (Cardinal) on Jun 06, 2007 at 11:59 UTC
    I just did a groups.google.com search for "SSL digital certificate LWP" and there were a couple of posts similar to your problem. The answer was that the certificate was not verified. I don't know if that is your roadblock, but you might want to google for the same phrase above, and you will find a few articles on making "self-certified certs".

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: Handling SSL digital certificate using LWP
by Anonymous Monk on Jun 06, 2007 at 06:39 UTC
    RTFM
    # DEBUGGING SWITCH / LOW LEVEL SSL DIAGNOSTICS $ENV{HTTPS_DEBUG} = 1; # DEFAULT SSL VERSION
      Here is the output after adding HTTPS_DEBUG.

      LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: POST https://sitename.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error

        Since you got an Internal Server Error you should check the Web Server error logs to see what message it spits out from your script.