After upgrading to Debian 8 with PHP 5.6.9 (change from PHP 5.4) I'm getting this warning when calling SOAP web service with HTTPS endpoint address:
Warning: SoapClient::__doRequest(): SSL operation failed with code 1. OpenSSL Error messages:
error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
followed by SoapFault:
Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers
Calling file_get_contents
with the web service URL doesn't trigger this warning.
I don't have any stream context options set for ssl on this SOAP call.
Do you have any clue what does this warning mean in this context and how to properly get rid of it?
EDIT
In my specific use case I'm calling two web service methods: A and B. Method A is working without warning, then some openssl methods are called on its result, and then method B is called which trigger the warning. When I remove the call to method A and load its result from cache, method B (and any other) works without warnings. It's bizarre - I need to investigate further.
EDIT2
I've extracted the problem and made it testable. It seems that following scenario causes this warning:
openssl_pkcs12_read
on PKCS#12 file with extra certificates.Below is example using some publicly available SOAP webservice and self-signed certificate.
<?php
$p12 = 'MIIMgQIBAzCCDEcGCSqGSIb3DQEHAaCCDDgEggw0MIIMMDCCBucGCSqGSIb3DQEHBqCCBtgwggbUAgEAMIIGzQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIHkgJ646mKooCAggAgIIGoFEhy5EmHjteHd4+Q8mUrtY74fszKgwvnhO20g5zneMP39UbQBW3MPSMmMNXuCSG0NqJeiMG/z4WESUMKchhiAe+l4+trbGnFHaNLes6qrItUvMaD2vOtIv4n2ywY99GS4G/dVpM1TWBoXFAQXqJkTXD1SxqX7J0iau+g5u9PV1yaiUAnhbRzsE3SuFdVJo0d3C66XbROKbn45Q+cPDOHCSmOTrQmANvUpFFmunQg2pROvJHd7uEU6KYkC4Hv+ofPDAtT2Uhy7UK2LAW9YoP48SRvkSfOS0s9S8ZvMKB4Czrx+mg5iY+KeacMa2voYQ0gRWm7obAHrzpW3s4nmYKGEi13mqn+fH2NjhbQKRcxfn57iAgXKOBOT3NmvDZA3hMvj1XI7LGLBAqS0Rwa+1rt8NNUbAiYd6S+HbC8r1HbtMmJEd2x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FQqbCuO22u0Q6r2bDPqDxACP5S2utJnD5yFaFuEIESYn1KlAXJoPFiRO4K4iRpspIZM1KY7/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());
Could somebody test this script? In PHP Version 5.6.9-0+deb8u1
with OpenSSL 1.0.1k 8 Jan 2015
I've got no second result of GetVersion
call and the warning and error.
EDIT3
Same result in PHP 7 Alpha 1. Reported as Bug #69882.
I've confirmed that this is PHP bug, and was introduced in PHP 5.6.7, in commit fd4641696cc67fedf494717b5e4d452019f04d6f.
The workaround is to call openssl_error_string()
after
openssl_pkcs12_read()
.
A pull request has been submitted to address this issue - merged
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With