简体   繁体   中英

PHP7 cURL and SOAP request SSL failing

I'm using PHP 7.0.25 in a vagrant VM with ubuntu 16.04

I need to make a request to this SOAP API: https://ws.ocasa.com/testecommerce/service.asmx?wsdl

Both php curl and SoapClient are failing

With SoapClient I'm doing this (also tried with no options at all, and just the cache_wsdl part):

$options = array(
    'cache_wsdl' => 0,
    'trace' => 1,
    'stream_context' => stream_context_create(array(
          'ssl' => array(
               'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
          )
    ))
);

$wsdl = 'https://ws.ocasa.com/testecommerce/service.asmx?wsdl';
$client = new \SoapClient( $wsdl, $options);

Giving me this error:

[SoapFault]
SOAP-ERROR: Parsing WSDL: Couldn't load from ' https://ws.ocasa.com/testecommerce/service.asmx?wsdl ' : failed to load external entity "https:
//ws.ocasa.com/testecommerce/service.asmx?wsdl"

With php curl I endend getting this error:

Unknown SSL protocol error in connection to ws.ocasa.com:443

I cant get the page from the linux curl command line without a problem (from inside the VM, of course)

curl -I https://ws.ocasa.com/testecommerce/service.asmx?wsdl -v

The SSL connection is using TLS1.0 / RSA_3DES_EDE_CBC_SHA1

I tested adding

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

and also tried adding the CA certs: (also tried adding them in the php.ini)

curl_setopt($ch, CURLOPT_CAINFO, '/vagrant/cacert.pem');

Something very strange is that I can curl some other https sites without problem like secure.php.net usgin php curl.

Also, there is no "http" version available to get rid of the whole SSL problem.

Any ideas? I'm missing some dependency maybe? openssl is installed.

Thanks for your time.

Well, I kinda found a solution...

With curl (the CURLOPT_SSLVERSION makes the difference)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $wsdl);
curl_setopt($ch, CURLOPT_POSTFIELDS,  $xml); // $xml is the envelope (string)
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_0);

I couldn't make SoapClient work, even with the SOAP_SSL_METHOD_TLS option. I'll mark it as resolved, but if some finds how to make it work with SoapClient, that would be the real answer.

This helped me out with making the request (not the ssl part)

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