我正在连接到需要 SSL 文件的 WSDL。我创建了这个 php 脚本来连接到 SOAP API:
$url = "https://www.testsoap.nl/api/soap?wsdl";
$soapArr = array(
"soap_version"=>SOAP_1_1,
"trace"=>true,
"exceptions"=>true,
"local_cert"=>"certfile.p12",
"passphrase"=>"passwordhere"
);
$client = new SoapClient($url, $soapArr);
现在,当我尝试连接时,我会在错误日志中看到此错误:
[Fri Jan 10 11:08:21 2014] [error] [client 172.21.1.131] PHP fatal error :未捕获的 SoapFault 异常:[WSDL] SOAP-ERROR:解析 WSDL:无法从“https:/”加载/www.testsoap.nl/api/soap?wsdl':加载外部实体“https://www.testsoap.nl/api/soap?wsdl”失败\n 在/var/www/index.php:39\n堆栈跟踪:\n#0/var/www/index.php(39): SoapClient->SoapClient('https://www.tes...', Array)\n#1 {main}\n 抛出/var/www/index.php 第 39 行
第 39 行 = $client = new SoapClient($url, $soapArr);
我也尝试了这些数组选项,但是它们没有改变任何东西:
$soapArr = array(
"style"=>SOAP_DOCUMENT,
"use"=>SOAP_LITERAL,
"soap_version"=>SOAP_1_1,
"trace"=>true,
"authentication"=>SOAP_AUTHENTICATION_DIGEST,
"exceptions"=>true,
"local_cert"=>"certfile.p12",
"passphrase"=>"passwordhere",
"ssl_method"=>SOAP_SSL_METHOD_TLS
);
一些需要考虑的事情:
我可以在我的浏览器中安装此 SSL 证书文件并毫无问题地连接到 API。
当使用 soapUI 时(密码和证书)我也可以连接到 API
openssl 安装在我的 debian 服务器上
debianserver 可以连接到互联网
在debian服务器上安装了php-soap
我做了更多测试,发现当我不使用任何这样的证书时,我会遇到同样的错误:
$client = new SoapClient($url);
所以我必须假设证书没有像我预期的那样加载。
我发现了这个错误:https://bugs.php.net/bug.php?id=27777 在这里:http://www.php.net/manual/en/soapclient.soapclient.php#83474有人说这也算作 SSL 证书。
然而,阅读这些信息和可能的解决方案,我仍然没有进一步...
任何帮助将不胜感激。 提前致谢!
最佳答案
尝试使用
将您的证书从.p12
转换为.pem
openssl pkcs12 -in certfile.p12 -out certfile.pem -nodes -clcerts
关于PHP SoapClient SSL : Failed to load external entity (certificate not loaded),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21042162/