PHP:SOAP请求的证书链

时间:2014-04-22 08:38:00

标签: php web-services soap digital-signature digital-certificate

我有以下示例SOAP请求消息,

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v="http://incometaxindiaefiling.gov.in/ws/ds/common/v_1_0">
<soapenv:Header/>
<soapenv:Body>
<v:DITWSAuthInfoEle>
<v:userID>xxxxxxxxxx</v:userID>
<v:password>xxxxxxxxxx</v:password>
<v:certChain>xxxxxxxxxx</v:certChain>
<v:signature>xxxxxxxxxx</v:signature>
</v:DITWSAuthInfoEle>
</soapenv:Body>
</soapenv:Envelope>

我收到了身份验证详细信息和xyz.pfx文件。通过使用此文件,我获得了XML签名表示并将其添加到SOAP请求中。在这里,我的问题是如何获得certChain(证书链)以及如何将其添加到SOAP请求中。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

使用SoapClient,默认情况下验证服务器证书,您可以发送如下客户端证书:

$protected_url = "https://my-server/?wsdl";
$my_cert_file = "/my/path/to/mycert.pem";

$client = new SoapClient($protected_url, array('local_cert', $my_cert_file) );

或者,如果您的证书需要密码:

$client = new SoapClient("https://url.to.service/", array(
        'local_cert' => 'client_certificate.pem', 'passphrase' => 'PASSPHRASE',
        'cache_wsdl' => WSDL_CACHE_NONE
));

然后,如果您想查看xml,可以使用__getLastRequest

还要查看关于如何在PHP上使用SOAP和证书的详细解答:

Creating a PHP SOAP request with a certificate