使用HTTPS时,PHP 5.6中的SoapClient会发出“键值不匹配”的警告

时间:2015-06-09 11:34:08

标签: php soap openssl php-5.6

使用PHP 5.6.9升级到Debian 8后(从PHP 5.4更改)我在使用HTTPS端点地址调用SOAP Web服务时收到此警告:

Warning: SoapClient::__doRequest(): SSL operation failed with code 1. OpenSSL Error messages: 
error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch

接着是SoapFault:

Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers

使用网络服务网址调用file_get_contents不会触发此警告。

我没有在此SOAP调用中为ssl设置任何流上下文选项。

您是否知道此警告在此背景下的含义以及如何正确摆脱它?

修改

在我的特定用例中,我正在调用两个Web服务方法:A和B.方法A在没有警告的情况下工作,然后在其结果上调用一些openssl方法,然后调用方法B来触发警告。当我删除对方法A的调用并从缓存加载其结果时,方法B(和任何其他)在没有警告的情况下工作。这很奇怪 - 我需要进一步调查。

EDIT2

我已经解决了问题并使其可测试。似乎以下情况会导致此警告:

  1. 使用HTTPS端点调用一些SOAP方法。
  2. 使用额外证书在PKCS#12文件上调用openssl_pkcs12_read
  3. 再次使用HTTPS端点调用一些SOAP方法。它会引起警告和SoapFault。
  4. 以下是使用一些公开的SOAP Web服务和自签名证书的示例。

    <?php
    
    $p12 = 'MIIMgQIBAzCCDEcGCSqGSIb3DQEHAaCCDDgEggw0MIIMMDCCBucGCSqGSIb3DQEHBqCCBtgwggbUAgEAMIIGzQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIHkgJ646mKooCAggAgIIGoFEhy5EmHjteHd4+Q8mUrtY74fszKgwvnhO20g5zneMP39UbQBW3MPSMmMNXuCSG0NqJeiMG/z4WESUMKchhiAe+l4+trbGnFHaNLes6qrItUvMaD2vOtIv4n2ywY99GS4G/dVpM1TWBoXFAQXqJkTXD1SxqX7J0iau+g5u9PV1yaiUAnhbRzsE3SuFdVJo0d3C66XbROKbn45Q+cPDOHCSmOTrQmANvUpFFmunQg2pROvJHd7uEU6KY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rXkczf6zd2uGDY85g4aoK2ozmkf0/IUFL+ChpByXD0FqZ8szg/xOut0yR3wFFugLHMfBeR4QKb3ZFGX1g4i8HIejWqoRohnV2MpPGgfKB3AXBdkhQr7cFurtFe6PSI2UEDmdO6YLYuP3rkLJpyH6lBCqAcL7jFkKlzMnlrXEqnZ/eAsJpyAbm8QxbJLZiXFQqbCuO22u0Q6r2bDPqDxACP5S2utJnD5yFaFuEIESYn1KlAXJoPFiRO4K4iRpspIZM1KY7/xFsj4ssGjOY/6O+K0Sxmg+qLwpxCpBvk1leusNb9Ua6bEMGiWUTS+PptkMmou/cYycoIlsIFx/lzmxSi1IsI+x/SSlOj0V2+FnLW0to5DgmJj0Y6Cg9hyI5UGhLTdNjtgFv2VEZ5F862c6aehpsEUcN5lRAb75fxZWiAHptGPH+M6xLsH0e6jRCGGfaoz1nA/vGDTJbhvQh+gTuerjuhnxMLkXt58bpQNiC5KB3lY78dch+/TzElMCMGCSqGSIb3DQEJFTEWBBThvL9jHiqk9kxxa+fO4m1Klc0mWzAxMCEwCQYFKw4DAhoFAAQU2t4LC2xjLRH7pTlVgA3R6iJ7TYsECA+RO2Li8MyxAgIIAA==';
    
    $sc = new SoapClient('https://finanzonline.bmf.gv.at/fon/services/FileUploadWSI/wsdl/FileUploadWSIService.wsdl');
    
    var_dump($sc->GetVersion());
    
    $result = openssl_pkcs12_read(base64_decode($p12), $cert_data, 'qwerty');
    var_dump($cert_data);
    
    var_dump($sc->GetVersion());
    

    有人可以测试这个脚本吗?在PHP Version 5.6.9-0+deb8u1 OpenSSL 1.0.1k 8 Jan 2015 GetVersion我没有filter来电的第二个结果以及警告和错误。

    EDIT3

    PHP 7 Alpha中的结果相同1.报告为Bug #69882

1 个答案:

答案 0 :(得分:1)

我已经确认这是PHP错误,并在PHP 5.6.7中的提交fd4641696cc67fedf494717b5e4d452019f04d6f中引入。

解决方法是在之后调用openssl_error_string() openssl_pkcs12_read()

更新

已提交pull request来解决此问题 - merged