开发者

How to get SSL connection with PHP SOAP extension?

When trying to connect to an SSL endpoint with PHP SOAP extension on Windows I am getting the SoapFault "Could not connect to host". Client certi开发者_开发百科ficate is not a requirement of the service.

$sslOptions = array(
    'ssl' => array(
        'cafile' => "c:/inetpub/wwwroot/eServices/Server_DSA_Public_Certificate.pem",
        'allow_self_signed' => true,
        'verify_peer' => false,
     ),
);      
$sslContext = stream_context_create($sslOptions);

$clientArguments = array(
    'stream_context' => $sslContext,
    'trace' => true,
    'exceptions' => true,           
    'encoding' => 'UTF-8',
    'soap_version' => SOAP_1_1,
);

$oClient = new WSSoapClient("c:/inetpub/wwwroot/eServices/svc.wsdl", $clientArguments);  
// WSSoapClient extends SoapClient to add a WS-Security UsernameToken header    

$oClient->__setUsernameToken("myusername", "mypassword");   
return $oClient->__soapCall($operation, $request);

I converted to .pem format a self-signed server certificate (.cer) that I was given and am passing that in as 'cacert'.

Am able to access the service perfectly using soapUI with the same wsdl.

Question: Do I need to put the server certificate into some trust store? I did already use Internet Explorer to add it into 'Trusted Root Certification Authorities'.

Question: By passing in 'cacert', is it enough for PHP to know it can trust the server?

Any help or suggestions would be much appreciated.


When I ran the code under Apache (using XAMPP) it worked first time. My problem must have been somewhere in the configuration of IIS or PHP.

Setting cacert was superfluous.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜