Google Php Oauth登录错误无法找到系统CA捆绑包

Dan*_*ide 2 php oauth ca ssl-certificate

我正在关注这个例子但是在$ client-> authenticate上得到一个错误($ _ GET ['Code']); 正在返回代码值,但不会进行身份验证.错误是

致命错误:未捕获的异常'RuntimeException',消息'在任何公共系统位置都找不到系统CA包.早于5.6的PHP版本未正确配置为默认使用系统的CA捆绑包.为了验证对等证书,您需要将磁盘上的路径提供给"验证"请求选项的证书包:http://docs.guzzlephp.org/en/latest/clients.html#verify.如果您不需要特定的证书包,那么Mozilla提供了一个常用的CA包,可以在这里下载(由cURL的维护者提供):https://raw.githubusercontent.com/bagder/ca-bundle/master/ ca-bundle.crt.在磁盘上有可用的CA捆绑包之后,可以将'openssl.cafile'PHP ini设置设置为指向文件的路径,从而省略'verify'请求选项.有关详细信息,请参阅http://curl.haxx.se/docs/sslcerts.html.在/base/data/home/apps/s~solomon-1/1.388711045841969234/google-api-php-client/vendor/guzzlehttp/ringphp/src/Client/Cli in/base/data/home/apps/s~solomon第51行的-1/1.388711045841969234/google-api-php-client/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php

??

Wil*_*tin 5

查看GoogleGuzzle的代码,您可能需要在设置Google客户端时和authenticate()通话前通过执行以下操作来指定证书捆绑包的位置:

$client->setHttpClient(new GuzzleHttp\Client(['verify'=>'path\to\your\cert-bundle']));
Run Code Online (Sandbox Code Playgroud)

这将覆盖默认行为,并允许您指定捆绑包的位置.

您还可以通过设置verifyfalse:来测试这是正确的方向:

$client->setHttpClient(new GuzzleHttp\Client(['verify'=>false]));
Run Code Online (Sandbox Code Playgroud)

这基本上会告诉curl不要验证主机和对等方.