<?php
putenv(
'GOOGLE_APPLICATION_CREDENTIALS=' . __DIR__ . '/google-credentials.json'
);
require 'vendor/autoload.php';
use Google\Cloud\Firestore\FirestoreClient;
$firestore = new FirestoreClient();
$categories_ref = $firestore->collection('categories');
$document_ref = $categories_ref->document('foobar');
$snapshot = $document_ref->snapshot();
print_r($snapshot['name']);
TestFirestore~ php .\index.php
PHP Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\Users\info\Projects\TestFirestore\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:186
Stack trace:
#0 C:\Users\info\Projects\TestFirestore\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(149): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 C:\Users\info\Projects\TestFirestore\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(102): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 C:\Users\info\Projects\TestFirestore\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 C:\Users\info\Pro in C:\Users\info\Projects\TestFirestore\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186
Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\Users\info\Projects\TestFirestore\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186
GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\Users\info\Projects\TestFirestore\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186
Call Stack:
0.0006 408736 1. {main}() C:\Users\info\Projects\TestFirestore\index.php:0
0.2105 4631472 2. Google\Cloud\Firestore\DocumentReference->snapshot() C:\Users\info\Projects\TestFirestore\index.php:14
0.2105 4631472 3. Google\Cloud\Firestore\DocumentReference->createSnapshot() C:\Users\info\Projects\TestFirestore\vendor\google\cloud-firestore\src\DocumentReference.php:347
0.2106 4631472 4. Google\Cloud\Firestore\DocumentReference->getSnapshot() C:\Users\info\Projects\TestFirestore\vendor\google\cloud-firestore\src\SnapshotTrait.php:61
0.2106 4632304 5. Google\Cloud\Firestore\Connection\Grpc->batchGetDocuments() C:\Users\info\Projects\TestFirestore\vendor\google\cloud-firestore\src\SnapshotTrait.php:122
0.2106 4634208 6. Google\Cloud\Firestore\Connection\Grpc->send() C:\Users\info\Projects\TestFirestore\vendor\google\cloud-firestore\src\Connection\Grpc.php:108
0.2106 4634232 7. Google\Cloud\Core\GrpcRequestWrapper->send() C:\Users\info\Projects\TestFirestore\vendor\google\cloud-core\src\GrpcTrait.php:82
Disallow SSL verification on vendor\google\auth\src\HttpHandler\HttpHandlerFactory.php line 34:
$client = $client ?: new Client(['verify' => false]);
Hey @leocavalcante, thank you for raising this - we do have a way to programmatically set the verify flag to false on the guzzle client so you don't need to modify your vendor directory:
use Google\Cloud\Firestore\FirestoreClient;
use GuzzleHttp\Client;
use Psr\Http\Message\RequestInterface;
$guzzleClient = new Client(['verify' => false]);
$firestore = new FirestoreClient([
'authHttpHandler' => function (RequestInterface $request, array $options = []) use ($guzzleClient) {
return $guzzleClient->send($request, $options);
}
]);
Let me know if it helps! :)
Awesome, thank you! It did worked.
Most helpful comment
Hey @leocavalcante, thank you for raising this - we do have a way to programmatically set the
verifyflag to false on the guzzle client so you don't need to modify your vendor directory:Let me know if it helps! :)