【问题标题】:Google Oauth2.0 No sytem CA bundle could be foundGoogle Oauth 2.0 找不到系统 CA 捆绑包
【发布时间】:2017-01-21 19:25:24
【问题描述】:

这是我的代码

require_once 'core_php/google-api-php-client-2.0.2_PHP54/vendor/autoload.php';

session_start();

$client = new Google_Client();
$client->setAuthConfigFile
($_SERVER['SR_WEB_CPANEL_PATH'].'asserts/php/client_secret.json');
$client->setRedirectUri('http://..../googleapi/oauth2callback.php');
$client->addScope(Google_Service_Drive::DRIVE_METADATA_READONLY);

if (! isset($_GET['code'])) {
  $auth_url = $client->createAuthUrl();
  header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {

    $client->setHttpClient(new GuzzleHttp\Client(['verify'=>'C:/Windows/System32/curl-ca-bundle.crt']));

  $client->authenticate($_GET['code']);
  $_SESSION['access_token'] = $client->getAccessToken();
  $redirect_uri = '/googleapi/index.php';
  header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}

然后它有一个致命错误:

致命错误:未捕获的异常“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。

我正在使用 PHP 5.4。 我尝试从错误消息提供的链接下载 CA 包。 并在 php.ini 中添加了两行

openssl.cafile = 'C:/Windows/System32/curl-ca-bundle.crt'
curl.cainfo = 'C:/Windows/System32/cacert.pem'

还是不行。

有人可以帮忙吗?非常感谢。

【问题讨论】:

  • 您的curl.cainfo... 条目是否在[curl] 部分下?
  • 是的。我只取消注释 curl.cainfo = 'C:/Windows/System32/cacert.pem'

标签: php oauth guzzle google-authentication


【解决方案1】:

实际上,我不知道会发生什么。我终于安装了 PHP 5.6。

【讨论】:

    猜你喜欢
    • 2016-05-05
    • 2019-07-07
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-06
    相关资源
    最近更新 更多