我正在尝试将WSDL与php native SOAPCLIENT配合使用以发送local_cert,但我总是得到响应,请求中没有证书。这是代码:
$local_cert = "cert.pem";
try{
$client = new SoapClient($wsdl,array(
"trace" => 1,"exceptions" => true,"use" => SOAP_ENCODED,"soap_version" => SOAP_1_1,"encoding" => 'UTF-8',"local_cert" => $local_cert,'authentication' => SOAP_AUTHENTICATION_DIGEST,'cache_wsdl' => WSDL_CACHE_NONE,));
$functionName = "Ping";
$request_param = array(
);
$res = $client->__call( $functionName,$request_param );
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->__getLastRequest(),ENT_QUOTES) . '</pre>';
echo '<pre>'.var_dump($res,ENT_QUOTES) .' </pre>';
} catch ( SoapFault $e ) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode},faultstring: {$fault->faultstring})",E_USER_ERROR);
$res = null;
}
cert.pem文件与三个文件ca.pem,client.pem和key.pem组合在一起
使用NUSOAPCLIENT并发送三个单独的证书文件,如下所示:
$crt = "ca.pem";
$key = "key.pem";
$pem = "client.pem";
$client->authtype = 'certificate';
$client->certRequest['sslcertfile'] = ($pem); # file containing the user's certificate
$client->certRequest['sslkeyfile'] = ($key); # file containing the private key
$client->certRequest['cainfofile'] = ($crt); # file containing the root certificate
there is expected response from WS.