简体   繁体   中英

PHP SoapClient over selfsigned certificate, SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://

I browsed the net for three days and I still can not solve my problem... That's why I ask for your help :)

I try to call a web servcice over https with selfsigned certificate and i get the following error : SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://...

My code :

$streamContext = stream_context_create(array(
    'ssl' => array(
        'verify_peer' => false,
        'allow_self_signed' => true
     )
));
$client = new SoapClient("https://DOMAIN/ws.php?wsdl", array(
    'trace' => true,
    'stream_context' => $streamContext
));
$client->method($params);

I tried to :

  • Change values of "verify_peer" and "allow_self_signed" options ;
  • Replace "ssl" key by "https" in stream_context array ;
  • Load the WSDL file locally but i get the following error : Could not connect to host (my endpoint : https://DOMAIN/ws.php );
  • Clear my client cache ;
  • Use Zend_Soap_Client and nusoap library.

Also, I checked the connection between the client and the server with the following commands "ping DOMAIN" and "telnet DOMAIN 443" and everything is ok.

It seems the "stream_context" option is ignored or the problem is elsewhere ?! Is it a php Bug ?!

All suggestions will be appreciated. Thx

I had a very similar problem and I added 'verify_peer_name' => false to the stream context. So...

$streamContext = stream_context_create(array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
     )
));

Editor's note : disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you'll be vulnerable to a Man-in-the-Middle Attack . Be sure you fully understand the security issues before using this as a solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM