Google-cloud-php: PHP Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate

Created on 16 Apr 2019  路  2Comments  路  Source: googleapis/google-cloud-php

Environment details

  • Microsoft Windows 10.0.17763
    Win32NT
  • PHP 7.3.2 (cli) (built: Feb 5 2019 22:55:35) ( ZTS MSVC15 (Visual C++ 2017) x64 )
    Zend Engine v3.3.2
    Xdebug v2.7.0
  • "google/cloud-firestore": "^1.4"

Steps to reproduce

  1. Just follow the lib's quickstart: https://googleapis.github.io/google-cloud-php/#/docs/cloud-firestore/v1.4.0/firestore/readme

Code example

<?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']);

Problem

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

Workaround

Disallow SSL verification on vendor\google\auth\src\HttpHandler\HttpHandlerFactory.php line 34:

$client = $client ?: new Client(['verify' => false]);
core question

Most helpful comment

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! :)

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Najtmare picture Najtmare  路  6Comments

joseflorido picture joseflorido  路  3Comments

codeflorist picture codeflorist  路  5Comments

smalot picture smalot  路  6Comments

castaneai picture castaneai  路  4Comments