ssl mutual authentication in perl

Here is a perl script to invoke web service using SSL mutual authentication.

use LWP::UserAgent;
use HTTP::Request::Common;

my $request = << REQ;
# message here

# client certificate support
$ENV{HTTPS_CERT_FILE} = 'test.crt';
$ENV{HTTPS_KEY_FILE} = 'test.key';

# CA cert peer verification
$ENV{HTTPS_CA_FILE} = 'ca.crt';

my $ua = new LWP::UserAgent;
my $res = $ua->request(POST 'https://test.com',
SOAPAction => 'http://test.com/operationA',
Content_Type => 'application/xml',
Content => $request);

print $res->code."\n";
print $res->content."\n";

print "Work is done. \n\n";


mathieu said...

For some reason $ENV{HTTPS_CA_FILE} = 'ca.crt'; does not work for me but it works when Iremove it.

For everybody information, $ENV{HTTPS_DEBUG} = 1 is really useful to understand what is going on and what is going wrong

Anonymous said...

Parkinson's Disease is a great deal defined as a parkinsonian syndrome that is idiopathic having the end of his forget me drug, went to a nutritionist who discussed his options with him.

my website Parkinson's disease specialists Lenoxville