【问题标题】:What are the possible reasons for cURL error 60 on an HTTPS site?HTTPS 站点上出现 cURL 错误 60 的可能原因是什么?
【发布时间】:2012-12-21 10:28:22
【问题描述】:

在网上搜索之后,我真的无能为力了。我知道这个问题已经被问过好几次了,但没有一个解决方案能解决我的问题。我想知道 curl 错误 60 是否还有其他已知原因:“SSL 证书问题,验证 CA 证书是否正常”。

我已将 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);

【问题讨论】:

标签: php curl https


【解决方案1】:

你可以试试这个:-

$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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-10
    • 2013-06-25
    • 2011-05-22
    • 1970-01-01
    • 1970-01-01
    • 2011-11-18
    • 2014-10-08
    相关资源
    最近更新 更多