cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

CURL证书错误问题正确解决方法

方法1:自己自己下载一个根证书(不推荐)
下载地址:https://github.com/bagder/ca-bundle

// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
// curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
# curl_setopt($ch, CURLOPT_CAPATH, __DIR__);
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . '/ca-bundle.crt');

方法2:自动找到系统里的证书路径(推荐)

# 安装
composer require composer/ca-bundle
# 通过下面方法即可返回证书路径
\Composer\CaBundle\CaBundle::getSystemCaRootBundlePath()
// curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
// curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
# curl_setopt($ch, CURLOPT_CAPATH, __DIR__);
curl_setopt($ch, CURLOPT_CAINFO, \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath());

GuzzleHttp https证书问题解决

$client = new \GuzzleHttp\Client([
    \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath()
]);

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注