Php ssl错误谷歌驱动器api
我正在使用PHP库检索文件或将其上载到Google drivePhp ssl错误谷歌驱动器api,php,ssl,curl,google-drive-api,google-api-php-client,Php,Ssl,Curl,Google Drive Api,Google Api Php Client,我正在使用PHP库检索文件或将其上载到Google drive include_once ROOT.'/google-api-php-client/vendor/autoload.php'; $client = new Google_Client(); $credentialsFile = ROOT.'/google-api-php-client/service_account.json'; if (!file_exists($credentialsFile)) { throw ne
include_once ROOT.'/google-api-php-client/vendor/autoload.php';
$client = new Google_Client();
$credentialsFile = ROOT.'/google-api-php-client/service_account.json';
if (!file_exists($credentialsFile)) {
throw new RuntimeException('Service account credentials Not Found!');
}
$client->setAuthConfig($credentialsFile);
$client->setScopes(Google_Service_Drive::DRIVE);
$service = new Google_Service_Drive($client);
/**
* Проверка существования папки для документов
*/
$optParams = array(
'q' => "name='Документы'"
);
$results = $service->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
exit('Нет папки для документов');
} else {
foreach ($results->getFiles() as $file) {
$papka_doc = $file->getId();
}
}
一切正常,但几天前,出现了一个错误:
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)
未捕获异常“GuzzleHttp\\exception\\RequestException”,消息为“cURL错误60:SSL证书问题:无法获取本地颁发者证书(请参阅http://curl.haxx.se/libcurl/c/libcurl-errors.html)
有什么问题吗?试试这个
首先,您应该下载curl.cert文件
curl https://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt
其次,设置此证书
$client->getHttpClient()->setDefaultOption('verify', '[Certificate File Path]');
Centos默认路径
/etc/pki/tls/certs/ca-bundle.crt
不幸的是,这种方法没有帮助