I am having difficulty curling an HTTPS url that uses TLS 1.2, in my curl operation- I post my login data into the website and save it in cookiefile. The error message I am getting is this:
"API Error:SSL connect error"
I have tried setting curl_setopt($ch, CURLOPT_POST)
to 6 but that does not seem to work, any suggestions?
Versions I am using:
OpenSSL version is 1.0.2b CURL version is 7.49.1 PHP is 5.5 Here is the code:
public function curl_request($url, $data, $method = 'GET', $headers = array(), $ssl_verify = false)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $ssl_verify);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ssl_verify);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_HTTP200ALIASES, range(400, 599));
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
if ($method == 'POST')
{
curl_setopt($ch, CURLOPT_POST, 6);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
$resp = curl_exec($ch);
if(curl_errno($ch))
{
throw new Exception('Unleashed API Error:' . curl_error($ch));
}
//print("<pre>" . print_r($resp, true). "</pre>")
$info = curl_getinfo($ch);
curl_close($ch);
$output = array();
$output['resp'] = $resp;
$output['info'] = $info;