具有通过SSL证书的PHP SOAP客户端 [英] PHP SOAP client with certificates over SSL

查看:213
本文介绍了具有通过SSL证书的PHP SOAP客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码设置Soap客户端:

I'm trying to set up a Soap client with the following code:

<?php
$wsdl           = 'https://domain.com/?wsdl';
$endpoint       = 'https://domain.com';
$certificate    = dirname(__FILE__) . '/CertWithKey.pem';
$password       = 'pwd';

$options = array(
    'location'      => $endpoint,
    'keep_alive'    => true,
    'trace'         => true,
    'local_cert'    => $certificate,
    'passphrase'    => $password,
    'cache_wsdl'    => WSDL_CACHE_NONE
);

try {
    $soapClient = new SoapClient($wsdl, $options);
} catch(Exception $e) {
    var_dump($e);
}

为我提供了一个带有.crt认证文件的.p12密钥文件.我使用openssl将.p12文件转换为.pem文件,然后将其与.crt文件合并. CertWithKey.pem对我来说不错,文件中有两个证书块.

I was given a .p12 key-file with a .crt certification file. Using openssl I've converted the .p12-file to a .pem-file and then merged it with the .crt-file. The CertWithKey.pem looks good to me, two certificate-blocks are in the file.

无论我尝试做什么,我都会不断收到消息SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://domain.com/?wsdl' : failed to load external entity "https://domain.com/?wsdl"的异常.

No matter what I try to do, I keep getting an exception with the message SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://domain.com/?wsdl' : failed to load external entity "https://domain.com/?wsdl".

与对方通话后,他们确认有一个请求传入,但他们正在记录以下错误:ssl handshake interrupted by system [hint: stop button pressed in browser?!].

After phoning with the remote party they acknowlegde that a request is coming in but they're logging this error: ssl handshake interrupted by system [hint: stop button pressed in browser?!].

由于到目前为止我在网上找不到任何有用的信息,所以我想请你们对此事有所了解.

Since I didn't find any useful information on the net so far I figured to ask you guys for some insight on the matter.

任何建议都可以尝试?我正在运行PHP 5.3.8,并且该服务器的IP地址在远程方的防火墙中列出为白色.

Any suggestions what can be tried? I'm running PHP 5.3.8 and the server's IP-address is white listed in the firewall at the remote party.

推荐答案

我已解决此问题.我认为,由于与此问题相关的问题数量众多,并且解决方案数量众多,因此其他人将从该解决方案中受益.去吧:

I've fixed this problem. I think, due to the number of questions regarding this issue and number of different solutions, others will benefit from the solution. Here goes:

我使用openssl CLI程序将.p12密钥文件转换为.pem密钥文件.诀窍是转换发生的方式.

I used the openssl CLI program to convert the .p12 key-file to a .pem key-file. The trick is the way the conversion takes place.

首先,我使用此命令对其进行了转换,但遇到了问题中所述的问题:

First I converted it with this command and I had the issue as described in the question:

openssl pkcs12 -in key.p12 -out key.pem -nodes -clcerts

虽然以下命令确实有效:

While the command below did the actual trick:

openssl pkcs12 -in key.p12 -out key.pem -clcerts

有关更多信息,请参见我使用的来源: https://community.qualys.com/docs/DOC-3273

For more info please see the source I used: https://community.qualys.com/docs/DOC-3273

这篇关于具有通过SSL证书的PHP SOAP客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆