简体   繁体   中英

Hostgator issue with curl: SSL connect error, error no: 35

I am trying to send curl request to another domain, returns

ssl connection error with error no. 35 on hostgator.

Code:

$url= $endpoint . "?".http_build_query($data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);


$res = curl_exec($curl);
if(curl_error($curl))
{
    echo curl_errno($curl);
    echo 'error:' . curl_error($curl);
}

This issue is specific to hostgator

Please let me know how can I get rid of the ssl error

Use boolean value instead of 0 or 1 in place of $value field

Syntax - bool curl_setopt ( resource $ch , int $option , mixed $value )

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_FORBID_REUSE, true);
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);

Note:

Better use the default(CURL_SSLVERSION_DEFAULT). Setting it to CURL_SSLVERSION_TLSv2 or CURL_SSLVERSION_TLSv2 is very dangerous given the known vulnerabilities in SSLv2 and SSLv3.

Reference :- http://php.net/manual/en/function.curl-setopt.php

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