Perl:错误500无法连接证书验证失败

时间:2015-08-06 12:43:14

标签: perl

当我尝试使用PHP运行Perl脚本时遇到问题,下面是Perl脚本

use HandlePWRequestService;

my $certfile = "E:\perl\Cache-UserMySQL.p12";
my $certpw = "Welcome1";
my $system = "Test-MySQL";
my $account = "admin1";


#$ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0;
#$ENV{HTTPS_CA_DIR} = 'E:\perl';
#$ENV{HTTPS_CA_FILE} = 'E:\perl\parRootCA';
$ENV{HTTPS_PKCS12_FILE} = $certfile;
$ENV{HTTPS_PKCS12_PASSWORD} = $certpw;
$ENV{HTTPS_DEBUG} = 1;

my $pwservice = new HandlePWRequestService;
my @rc = $pwservice->handleRequestWS($system,$account);
print "rc=$rc[0], password=$rc[1]\n";

每当我尝试跑步时,我都会收到错误500 Certificate Verify Failed 我想知道是什么原因引起的?

以下是HandlePWRequestService的代码 HandlePWRequestService.pm

package HandlePWRequestService;

my %methods = (
handleRequestWS => {
endpoint => 'https://some_ip/HandlePWRequestService/HandlePWRequest',
soapaction => '',
namespace => 'http://ejb3.pwAccel.edmz.com/',
parameters => [
  SOAP::Data->new(name => 'systemName', type => 'xsd:string', attr => {}),
  SOAP::Data->new(name => 'accountName', type => 'xsd:string', attr => {}),
], # end parameters
  }, # end handleRequestWS
 ); # end my %methods

use SOAP::Lite;
use Exporter;
use Carp ();

use vars qw(@ISA $AUTOLOAD @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter SOAP::Lite);
@EXPORT_OK = (keys %methods);
%EXPORT_TAGS = ('all' => [@EXPORT_OK]);

sub _call {
    my ($self, $method) = (shift, shift);
    my $name = UNIVERSAL::isa($method => 'SOAP::Data') ? $method->name :    $method;
    my %method = %{$methods{$name}};
    $self->proxy($method{endpoint} || Carp::croak "No server address (proxy) specified")
    unless $self->proxy;
my @templates = @{$method{parameters}};
my @parameters = ();
foreach my $param (@_) {
    if (@templates) {
        my $template = shift @templates;
        my ($prefix,$typename) = SOAP::Utils::splitqname($template->type);
        my $method = 'as_'.$typename;
        # TODO - if can('as_'.$typename) {...}
        my $result = $self->serializer->$method($param, $template->name, $template->type, $template->attr);
        push(@parameters, $template->value($result->[2]));
    }
    else {
        push(@parameters, $param);
    }
}
$self->endpoint($method{endpoint})
   ->ns($method{namespace})
   ->on_action(sub{qq!"$method{soapaction}"!});
$self->serializer->register_ns("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd","wsu");
$self->serializer->register_ns("http://www.w3.org/2001/XMLSchema","xsd");
$self->serializer->register_ns("http://ejb3.pwAccel.edmz.com/","tns");
$self->serializer->register_ns("http://schemas.xmlsoap.org/wsdl/soap/","soap");
my $som = $self->SUPER::call($method => @parameters);
if ($self->want_som) {
    return $som;
}
 UNIVERSAL::isa($som => 'SOAP::SOM') ? wantarray ? $som->paramsall : $som->result : $som;
 }

 sub BEGIN {
    no strict 'refs';
    for my $method (qw(want_som)) {
    my $field = '_' . $method;
    *$method = sub {
        my $self = shift->new;
        @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
        }
    }
}
 no strict 'refs';
 for my $method (@EXPORT_OK) {
 my %method = %{$methods{$method}};
     *$method = sub {
    my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
        ? ref $_[0]
            ? shift # OBJECT
            # CLASS, either get self or create new and assign to self
            : (shift->self || __PACKAGE__->self(__PACKAGE__->new))
        # function call, either get self or create new and assign to self
        : (__PACKAGE__->self || __PACKAGE__->self(__PACKAGE__->new));
    $self->_call($method, @_);
}
 }

sub AUTOLOAD {
my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
return if $method eq 'DESTROY' || $method eq 'want_som';
die "Unrecognized method '$method'. List of available method(s):   @EXPORT_OK\n";
 }

 1;

1 个答案:

答案 0 :(得分:0)

很难确定HandlePWRequestService似乎是一个我们无法了解的私人模块。

但是看一下你的代码设置的环境变量,我猜想有一些可能使用LWP和朋友的HTTPS交互。所以我的第一个建议是取消注释关闭主机名验证的行,看看是否能解决问题。