cURL 错误 60:SSL 证书 prblm:无法获取本地颁发者证书
cURL error 60: SSL certificate prblm: unable to get local issuer certificate
我想使用 YouTube 数据收集上传到特定频道的视频列表 API。但是,在在线实施之前,我试图在离线环境(WAMPserver、PHP 5.5.12、Apache 2.4.9)上获取我的代码 运行。我正在使用以下代码:
require_once 'google-api-php-client-2.0.0-RC5/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName("SRC_Thor");
$client->setDeveloperKey("xxxxxxxxxxx");
$youtube = new Google_Service_YouTube($client);
$channelResponse = $youtube->channels->listChannels('contentDetails', []);
var_dump($channelResponse);
但是它给出了以下错误:
Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html
)'
我尝试添加最新版本的 cacert.pem
,因为 SO 上的大多数主题都提供了解决方案,但无济于事。
PCI-DSS 3.1 要求所有 SSL 仅支持 TLS 1.2,因此许多提供商只是关闭了除 TLS 1.2 之外的所有内容。我 运行 遇到过此类问题,其中 CURL 将未能降级握手视为未能验证 SSL 证书。尝试找到您的代码在哪里执行 CURL 调用并添加此行(请务必将 $ch
替换为您的代码使用的任何 CURL 句柄)
curl_setopt($ch, CURLOPT_SSLVERSION, 6); // Force TLS 1.2
看到我使用的是本地环境,我可以安全地禁用 SSL,我使用以下方法做到了这一点:
$guzzleClient = new \GuzzleHttp\Client(array( 'curl' => array( CURLOPT_SSL_VERIFYPEER => false, ), ));
$client->setHttpClient($guzzleClient);
其中 $client
是我的 Google_Client()。
如果您在 Windows 上使用 Xampp,我从 那里窃取了一个更好的答案,如果 Google 先向您展示这个问题会有所帮助。
在此处下载并提取 cacert.pem(一个干净的文件 format/data)
放入:
C:\xampp\php\extras\ssl\cacert.pem
将此行添加到您的 php.ini
curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"
重启你的webserver/Apache
$guzzleClient = new \GuzzleHttp\Client(['verify' => false]);
Guzzle 版本 6
您可以在
参考 Guzzle 文档
http://docs.guzzlephp.org/en/latest/request-options.html#verify
$guzzleClient = new \GuzzleHttp\Client(['verify' => false]);
对于开发和测试的本质,你有两种选择可以快速修复
- Use
$client = new GuzzleHttp\Client();
$request = $client->request('GET',$url, ['verify' => false]); //where $url is your http address
- follow @Pham Huy Anh answer's above then do this
$client = new GuzzleHttp\Client();
$request = $client->request('GET',$url, ['verify' => 'C:\xampp\php\extras\ssl\cacert.pem']);
希望对大家有所帮助。
通过从
link https://gist.github.com/VersatilityWerks/5719158/download
然后
保存在 C:\xampp\php\extras\ssl
然后编辑 php.ini。快速获取Php.ini见下图
enter image description here
然后停止并重新启动您的 apache。效果很好!!!
我使用 xamps,以上对我都不起作用
我试过了,它成功了
- 打开
vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php
并改变这个
$conf[CURLOPT_SSL_VERIFYHOST] = 2;
$conf[CURLOPT_SSL_VERIFYPEER] = true;
至此
$conf[CURLOPT_SSL_VERIFYHOST] = 0;
$conf[CURLOPT_SSL_VERIFYPEER] = FALSE;
这是一个临时解决方案,如果您更新此文件,更改将会丢失
我想使用 YouTube 数据收集上传到特定频道的视频列表 API。但是,在在线实施之前,我试图在离线环境(WAMPserver、PHP 5.5.12、Apache 2.4.9)上获取我的代码 运行。我正在使用以下代码:
require_once 'google-api-php-client-2.0.0-RC5/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName("SRC_Thor");
$client->setDeveloperKey("xxxxxxxxxxx");
$youtube = new Google_Service_YouTube($client);
$channelResponse = $youtube->channels->listChannels('contentDetails', []);
var_dump($channelResponse);
但是它给出了以下错误:
Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see
http://curl.haxx.se/libcurl/c/libcurl-errors.html
)'
我尝试添加最新版本的 cacert.pem
,因为 SO 上的大多数主题都提供了解决方案,但无济于事。
PCI-DSS 3.1 要求所有 SSL 仅支持 TLS 1.2,因此许多提供商只是关闭了除 TLS 1.2 之外的所有内容。我 运行 遇到过此类问题,其中 CURL 将未能降级握手视为未能验证 SSL 证书。尝试找到您的代码在哪里执行 CURL 调用并添加此行(请务必将 $ch
替换为您的代码使用的任何 CURL 句柄)
curl_setopt($ch, CURLOPT_SSLVERSION, 6); // Force TLS 1.2
看到我使用的是本地环境,我可以安全地禁用 SSL,我使用以下方法做到了这一点:
$guzzleClient = new \GuzzleHttp\Client(array( 'curl' => array( CURLOPT_SSL_VERIFYPEER => false, ), ));
$client->setHttpClient($guzzleClient);
其中 $client
是我的 Google_Client()。
如果您在 Windows 上使用 Xampp,我从
在此处下载并提取 cacert.pem(一个干净的文件 format/data)
放入:
C:\xampp\php\extras\ssl\cacert.pem
将此行添加到您的 php.ini
curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"
重启你的webserver/Apache
$guzzleClient = new \GuzzleHttp\Client(['verify' => false]);
Guzzle 版本 6
您可以在
参考 Guzzle 文档http://docs.guzzlephp.org/en/latest/request-options.html#verify
$guzzleClient = new \GuzzleHttp\Client(['verify' => false]);
对于开发和测试的本质,你有两种选择可以快速修复
- Use
$client = new GuzzleHttp\Client();
$request = $client->request('GET',$url, ['verify' => false]); //where $url is your http address
- follow @Pham Huy Anh answer's above then do this
$client = new GuzzleHttp\Client();
$request = $client->request('GET',$url, ['verify' => 'C:\xampp\php\extras\ssl\cacert.pem']);
希望对大家有所帮助。
通过从 link https://gist.github.com/VersatilityWerks/5719158/download 然后 保存在 C:\xampp\php\extras\ssl 然后编辑 php.ini。快速获取Php.ini见下图 enter image description here
然后停止并重新启动您的 apache。效果很好!!!
我使用 xamps,以上对我都不起作用
我试过了,它成功了
- 打开
vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php
并改变这个
$conf[CURLOPT_SSL_VERIFYHOST] = 2;
$conf[CURLOPT_SSL_VERIFYPEER] = true;
至此
$conf[CURLOPT_SSL_VERIFYHOST] = 0;
$conf[CURLOPT_SSL_VERIFYPEER] = FALSE;
这是一个临时解决方案,如果您更新此文件,更改将会丢失