cURL错误60:SSL证书问题:自签名证书(参见https://curl.haxx.se/libcurl/c/libcurl-errors.html)
我在我的 Laravel 7 项目和 XAMPP 7.4.5 中使用 Guzzle,我正在尝试对我的本地 API localhost/events_platforma/view/users 进行 GET 它工作正常,但是当我尝试向 https 发出 POST 请求时: //localhost/events_platforma/register 它失败并给出 cURL 错误和我的 API 在 SLIM 上。
我已经添加了这个文件
curl.cainfo = curl.cainfo="C:xamppphpextrassslcacert.pem"
但是还是报错
回答
本地主机的快速解决方案是使用 guzzle of verifyas false选项关闭证书验证。
下面是一个快速的小例子
use GuzzleHttpClient;
$client = new Client([
'base_uri' => 'http://exmaple.org'
]);
$client->request('GET', '/', ['verify' => false]);
如果您使用的是 laravel 提供的Http-client,您可以添加这样的 guzzle 选项,
$response = Http::withOptions([
'verify' => false,
])->get('http://example.org/');
笔记:
尽管甚至 guzzle 建议不要使用它,但如果您正在测试自己的 api,它可以工作。
尽管您只需提供路径就可以根据请求简单地添加证书。
Mozilla 提供了一个常用的 CA 包,可以在这里下载(由 cURL 的维护者提供)。
// Use a custom SSL certificate on disk.
$client->request('GET', '/', ['verify' => '/path/to/cacert.pem']);
从https://curl.se/docs/sslcerts.html阅读有关证书的更多信息。
了解更多关于从狂饮文档验证验证
THE END
二维码