ffrost has asked for the wisdom of the Perl Monks concerning the following question:
Objective: To connect from my machine to an external server using HTTPS. The connection will use the GET verb and the external server should return a message back to the client. As a security mechanism, the certificate for my client must be sent to the server as authentication.
I'm using LWP to get the response from the external server. I've run into two problems I'm not sure of. First, I am unsure if the LWP program is actually loading the certificate, which is in DER format. Second, since the server is responding with a 403 error I don't think they are getting my certificate. Am I loading the certificate correctly to send from my Windows machine to their external IIS server?
The DER certificate is valid and has not expired. It is not a self-signed certificate.
use LWP::UserAgent; use Data::Dumper; use Cwd; $cdir = getcwd; $endpoint = ‘https://omit/commotest'; $ua = LWP::UserAgent->new; $ua->ssl_opts(SSL_cert_file => "$cdir\\der.cer"); $ua->ssl_opts(SSL_use_cert => '1'); $response = $ua->get($endpoint); if ($response->is_success) { print Dumper $response; } else { print "Error: " . $response->status_line, "\n"; }
ICYMI: Here's the solution
$ua->ssl_opts(SSL_cert_file => 'privatekey.pfx'); $ua->ssl_opts(SSL_passwd_cb => sub { return "passwordvaluehere"; } ); $ua->ssl_opts(SSL_use_cert => '1');
|
|---|