min*_*us1 10 php https soap web-services
我正在使用旧版本的OpenSSL(OpenSSL 0.9.8o),我被迫使用较新的OpenSSL 1.0.1e-fips,因为我无法连接到WSDL:
Message: SoapClient::SoapClient(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
我需要禁用SSL认证检查,我试过:
$client = new SoapClient("https://IP:443/sdk/vimService?wsdl",
array(
"trace" => 1,
"location" => "https://IP:443/sdk/",
"stream_context" => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'allow_self_signed' => true,
)
)
)
)
);
Run Code Online (Sandbox Code Playgroud)
`
它抛出:
Message: SoapClient::SoapClient(): Peer certificate CN=localhost.localdom'与预期的CN =不匹配SAME IP AS IN SoapClient()'
然后我添加'peer_name'=> 'localhost.localdom',了stream_context然后它说XML文件是空的:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document
PHP 5.5
min*_*us1 26
哦,我找到了问题.
你可以使用稳定的PHP 5.5版本来避免这种混乱
最近我了解到错误:"看起来我们没有XML文档"是由于PHP版本引起的 - 5.5中的PHP 5.6就像一个魅力.
1)删除PHP 5.6中的SSL证书检查:
在5.6版本中,默认情况下启用了SSL认证,因此如果要禁用它,则必须传递上下文流:
"stream_context" => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
)
)
)
Run Code Online (Sandbox Code Playgroud)
2)删除?wsdl并添加.wsdl(有?wsdl,它没有让我烦恼)
<?php
$client = new SoapClient("https://IP:443/sdk/vimService.wsdl",
array(
"trace" => 1,
"location" => "https://IP:443/sdk/",
'exceptions' => 1,
"stream_context" => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
)
)
)
)
);
$soapmsg["_this"] = array( "_" => "ServiceInstance", "type" => "ServiceInstance");
$result = $client->RetrieveServiceContent($soapmsg);
$ServiceContent = $result->returnval;
$soapmsg = NULL;
$soapmsg["_this"] = $ServiceContent->sessionManager;
$soapmsg["userName"] = "USERNAME";
$soapmsg["password"] = "PASSWORD";
$result = $client->Login($soapmsg);
$UserSession = $result->returnval;
echo "User, " . $UserSession->userName . ", successfully logged in!\n";
$soapmsg = NULL;
$soapmsg["_this"] = $ServiceContent->sessionManager;
$result = $client->Logout($soapmsg);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13255 次 |
| 最近记录: |