【发布时间】:2011-05-05 11:44:49
【问题描述】:
在 Windows 上尝试使用 PHP SOAP 扩展连接到 SSL 端点时,我收到 SoapFault“无法连接到主机”。客户端证书不是服务的要求。
$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);
我将获得的自签名服务器证书 (.cer) 转换为 .pem 格式,并将其作为“cacert”传递。
我能够使用具有相同 wsdl 的 soapUI 完美地访问该服务。
问题:我需要将服务器证书放入某个信任库吗?我确实已经使用 Internet Explorer 将其添加到“受信任的根证书颁发机构”中。
问题:通过传入'cacert',PHP是否知道它可以信任服务器?
任何帮助或建议将不胜感激。
【问题讨论】:
标签: php soap ssl connection certificate