Reputation: 11
$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,
Upvotes: 1
Views: 4722
Reputation: 51
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.
Upvotes: 1