简体   繁体   English

错误 GuzzleHttp cURL 错误 60:SSL 证书

[英]Error GuzzleHttp cURL error 60: SSL certificate

Im trying to use the Google API, however, when I run it it shows me the following error:我尝试使用 Google API,但是,当我运行它时,它显示以下错误:

GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: u
    nable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl
    -errors.html) in C:\wamp64\www\apigmail\vendor\guzzlehttp\guzzle\src\Handler\Cur
    lFactory.php on line 187

Im using WAMP -Server PHP v 7.0.13我使用 WAMP -Server PHP v 7.0.13

现在您可以使用:

$client = new \GuzzleHttp\Client(['verify' => false ]);

You have to read your error code :) Its simple you have some SSL errors because your localhost enviroment cant get the data, because you didnt have any SSL certificate.您必须阅读您的错误代码:) 很简单,您有一些 SSL 错误,因为您的本地主机环境无法获取数据,因为您没有任何 SSL 证书。

But here is an solution of your problem in an another thread: cURL error 60: SSL certificate: unable to get local issuer certificate但这是另一个线程中您的问题的解决方案: cURL 错误 60:SSL 证书:无法获得本地颁发者证书

you have to add \\GuzzleHttp\\RequestOptions::VERIFY => false to the client config:您必须将\\GuzzleHttp\\RequestOptions::VERIFY => false到客户端配置中:

$this->client = new \GuzzleHttp\Client([
    'base_uri'                          => 'someAccessPoint',
    \GuzzleHttp\RequestOptions::HEADERS => [
        'User-Agent' => 'some-special-agent',
    ],
    'defaults'                          => [
        \GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 5,
        \GuzzleHttp\RequestOptions::ALLOW_REDIRECTS => true,
    ],
    \GuzzleHttp\RequestOptions::VERIFY  => false,
]);

it will set CURLOPT_SSL_VERIFYHOST and CURLOPT_SSL_VERIFYPEER in the CurlFactory::applyHandlerOptions() method它将在CurlFactory::applyHandlerOptions()方法中设置CURLOPT_SSL_VERIFYHOSTCURLOPT_SSL_VERIFYPEER

$conf[CURLOPT_SSL_VERIFYHOST] = 0;
$conf[CURLOPT_SSL_VERIFYPEER] = false;

From the GuzzleHttp documentation来自GuzzleHttp 文档

verify验证

Describes the SSL certificate verification behavior of a request.描述请求的 SSL 证书验证行为。

  • Set to true to enable SSL certificate verification and use the default CA bundle > provided by operating system.设置为 true 以启用 SSL 证书验证并使用操作系统提供的默认 CA 包 >。
  • Set to false to disable certificate verification (this is insecure!).设置为 false 以禁用证书验证(这是不安全的!)。
  • Set to a string to provide the path to a CA bundle to enable verification using a custom certificate.设置为字符串以提供 CA 包的路径以启用使用自定义证书的验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM