【问题标题】:PHP SoapClient SSL: Failed to load external entity (certificate not loaded)PHP SoapClient SSL:无法加载外部实体(未加载证书)
【发布时间】:2014-01-10 10:41:00
【问题描述】:

我正在连接到需要 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: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://www.testsoap.nl/api/soap?wsdl' : failed to load external entity "https://www.testsoap.nl/api/soap?wsdl"\n in /var/www/index.php:39\nStack trace:\n#0 /var/www/index.php(39): SoapClient->SoapClient('https://www.tes...', Array)\n#1 {main}\n thrown in /var/www/index.php on line 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 可以连接到互联网

  • php-soap 安装在 debian 服务器上

我做了更多的测试,发现当我不使用这样的任何证书时,我得到了同样的错误:

$client = new SoapClient($url);

所以我必须假设证书没有像我预期的那样加载。

我发现了这个错误:https://bugs.php.net/bug.php?id=27777 在这里:http://www.php.net/manual/en/soapclient.soapclient.php#83474 有人说这也适用于 SSL 证书。

但是,阅读此信息和可能的解决方案,我仍然没有进一步...

任何帮助将不胜感激。 提前致谢!

【问题讨论】:

    标签: php web-services soap ssl wsdl


    【解决方案1】:

    尝试将您的证书从 .p12 转换为 .pem 使用

    openssl pkcs12 -in certfile.p12 -out certfile.pem -nodes -clcerts
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2012-05-06
      • 2016-08-02
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      相关资源
      最近更新 更多