问题
In our firm I currently have script that connects to an outside vendor on HTTPS, via SSL. The script only performs server authentication. This is it:
use HTML::Parser;
use HTTP::Request::Common;
use LWP::UserAgent;
use XML::Simple;
local $ENV{HTTPS_CERT_FILE} = '../cert/abc.vendor.crt';
local $ENV{HTTPS_PROXY} = 'https://proxy.com:8080';
local $ENV{HTTPS_DEBUG} = 0;
my $vendor_server = 'https:abc.vendor.site.com';
my $xml = "XML code here";
my $request = (POST $vendor_server, Content_Type => 'text/xml; charset=utf-8', Content => $xml);
my $ua = LWP::UserAgent->new();
my $response = $ua->request($request);
if ( $response->is_success() ) {
return $response;
}
else {
return "Error message";
}
This is working as needed, but due to firm compliance and security, we now need to make this a 'Mutual Authentication' via self-signed cert. I tried changing the HTTPS_DEBUG to 1 and adding the following 2 lines after it. The 'myserver.crt' is an internally self-signed cert after I created the CSR (I hope I have those details correct, I'm not well versed in SSL, as is evident):
local $ENV{HTTPS_CA_DIR} = '../cert';
local $ENV{HTTPS_CA_FILE} = '../cert/myserver.crt';
But I'm getting the following error when I run the script:
Connecting to abc over SSL and sending POST
SSL_connect:before/connect initialization
SSL_connect:SSLv2/v3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL3 alert write:fatal:unknown CA
SSL_connect:error in SSLv3 read server certificate B
SSL_connect:error in SSLv3 read server certificate B
SSL_connect:before/connect initialization
SSL_connect:SSLv3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL3 alert write:fatal:bad certificate
SSL_connect:error in SSLv3 read server certificate B
SSL_connect:before/connect initialization
SSL_connect:SSLv2 write client hello A
SSL_connect:failed in SSLv2 read server hello A
Ticket FAILED
$VAR1 = '500 SSL negotiation failed: ';
What am I doing wrong?
Thank you for any and all help!
来源:https://stackoverflow.com/questions/16408312/mutual-authentication-ssl-with-self-signed-client-certificate