| [reply] |
I'm using LWP to post data to a > https server. The Server needs the certificate for Authentication. I have the Cert.pfx certificate which is given for the installation on to the browser. Using Openssl I could get the privatekey.pem and publickey.pem from the cert.pfx. I used the following commands to do that
openssl pkcs12 -in CERT.pfx -clcerts -out certonly.pem -nokeys
openssl pkcs12 -in CERT.pfx -clcerts -out keys.pem
openssl rsa -in keys.pem -pubout -out pubkey.pem -text
openssl rsa -in keys.pem -pubout -out pubkey.pem
openssl rsa -in keys.pem -pubin -text >private.key
openssl rsa -pubout <keys.pem >public.key
Now In my perl script I used the following code.
use LWP::UserAgent;
use HTTP::Cookies; #for testing
use LWP::Debug '+';
$cookie = new HTTP::Cookies( ignore_discard => 1 );
$ua = new LWP::UserAgent;
$ENV{https_proxy}="2342xxxxx:80";
$ua->proxy(http => $ENV{"HTTP_Proxy"}) if $ENV{"HTTP_Proxy"};
$ua->cookie_jar( $cookie );
$ua->agent("Mozilla/8.0"); #get the cookie
$ENV{HTTPS_VERSION} = '3';
$ENV{HTTPS_CERT_FILE} = '/certs/certonly.pem';
$ENV{HTTPS_KEY_FILE} = '/certs/keysnopass.pem';
#####$ENV{HTTPS_CA_FILE} = "some_file";
#####$ENV{HTTPS_CA_DIR} = "some_dir";
$request = new HTTP::Request('GET', 'https:///');
$res = $ua->request( $request );
if ($res->is_success) {
print "Success\n";
print "As_string: ", $res->as_string, "\n";
} else {
print "FAILED: ", $res->code, " ", $res->message, "\n";
}
But the server is not able to authnticate. I guess its looking for $ENV{HTTPS_CA_FILE} and $ENV{HTTPS_CA_DIR}. I don't know what to pass to these variables. Can you please advice me on this. I have the Cert.pfx file. How do I make the CA_file etc.
Please suggest me on this.Let me know if I am doing some thing wrong. Thanks in advance.
Regards,
Kris
| [reply] |
| [reply] |