在HTTPS站点上出现cURL错误60的可能原因是什么?


What are the possible reasons for cURL error 60 on an HTTPS site?

浏览了网页后,我真的是无计可施了。我知道这个问题已经被问过好几次了,但没有一个解决方案能解决我的问题。我想知道是否有任何其他已知的原因curl错误60:"SSL证书问题,验证CA证书是OK的"。

我已经将CURLOPT_CAINFO设置为pem文件(也尝试过crt),并且在尝试访问pem文件时检查了权限不足。

下面是代码:
$url = 'https://example.com/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 
curl_setopt($ch, CURLOPT_CAINFO, "/usr/local/apache2/htdocs/server/html/cacert.pem");
$response = curl_exec($ch);
...do something
curl_close($ch);

你可以试试:-

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, **'https://example.com/'**);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
// Get the response and close the channel.
$response = curl_exec($ch);