1
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $xml_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);

$xml = curl_exec($ch);

if(curl_exec($ch) === false) 
{ echo curl_error($ch); }
else 
{ echo 'Operation completed without any errors'; }

curl_close($ch);
return $xml;

Above code is giving below error.

Unknown SSL protocol error in connection to api.site.com:443

As per suggested by many people that below code will resolve above issue but it is not helping. Still getting same error.

curl_setopt ($ch, CURLOPT_SSLVERSION, 3);

I tried below also as per suggestions but still getting same error.

curl_setopt ($ch, CURLOPT_SSLVERSION, 'CURL_SSLVERSION_SSLv3' );

Please suggest what else I should put in code to fix this error.

Thank you,

2
  • which curl version are you using? Commented Mar 23, 2018 at 8:23
  • @DarshanJain, libcurl/7.21.0 OpenSSL/0.9.8q zlib/1.2.3 - this is mentioned in php info. Commented Mar 23, 2018 at 8:32

1 Answer 1

1

You could check which TLS version the website uses with curl verbose mode:

curl_setopt($curl, CURLOPT_VERBOSE, true);

Where the output will be like this:

...
SSL connection using TLS1.0 / RSA_3DES_EDE_CBC_SHA1
...

Then set CURLOPT_SSL_CIPHER_LIST like this:

curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, "TLSv1");

Where "TLSv1" is the TLS version the website uses.

Changing SSL version and VERIFY_PEER/HOST in curl options didn't solve my problem, but this approach did.

Sign up to request clarification or add additional context in comments.

2 Comments

Using PHP curl, where does this output show up? I'm using CURLOPT_RETURNTRANSFER, true, and added CURLOPT_VERBOSE, true, and sending a head request with CURLOPT_NOBODY, true, but the call to curl_exec returns an empty string, and curl_getinfo() does not produce it.
Oops, I see this is answered here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.