Skip to content
Advertisement

I have an error while using firebase php which is cURL error 35

I am trying to use php with firebase

after installing the package “composer require kreait/firebase-php ^4.0”

and adjusting my firebase

it shows me that error:

Fatal error: Uncaught GuzzleHttpExceptionConnectException: cURL error 35: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to ff64t.firebaseio.com:443 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:xampphtdocsdashboardwebservicephp_firebasevendorguzzlehttpguzzlesrcHandlerCurlFactory.php:200 Stack trace: #0 C:xampphtdocsdashboardwebservicephp_firebasevendorguzzlehttpguzzlesrcHandlerCurlFactory.php(155): GuzzleHttpHandlerCurlFactory::createRejection(Object(GuzzleHttpHandlerEasyHandle), Array) #1 C:xampphtdocsdashboardwebservicephp_firebasevendorguzzlehttpguzzlesrcHandlerCurlFactory.php(105): GuzzleHttpHandlerCurlFactory::finishError(Object(GuzzleHttpHandlerCurlHandler), Object(GuzzleHttpHandlerEasyHandle), Object(GuzzleHttpHandlerCurlFactory)) #2 C:xampphtdocsdashboardwebservicephp_firebasevendorguzzlehttpguzzlesrcHandlerCurlHandler.php(43): GuzzleHttpHandlerCurlFactory::finish(Object(GuzzleHttpHandlerCurlHandler), Object(Guz in C:xampphtdocsdashboardwebservicephp_firebasevendorkreaitfirebase-phpsrcFirebaseExceptionApiException.php on line 40

my php code is so simple:

 <?php
 require_once './vendor/autoload.php';
 use KreaitFirebaseFactory;
     use KreaitFirebaseServiceAccount;
 $serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/secret/clone-7ef2-642f.json');
 $firebase = (new Factory)
    ->withServiceAccount($serviceAccount)
    //->withDatabaseUri("https://ff64t.firebaseio.com")
    ->create();
    $database = $firebase->getDatabase();
    $ref = $database->getReference('users');
    $res = $ref->getChild('1z7ni171Hwgq8fdnandRNjfxBfw2')->getChild('name')->getValue();
    var_dump($res);

?>

so anyone has faced something like that and how to solve this problem

I’ve tried many solutions but none of them works.

I tried to reinstall curl and put it like system variable I also tried to add

curl_setopt($easy->handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

to make curl deal with IPV4… it gave me a new error which is:

Fatal error: Uncaught GuzzleHttpExceptionRequestException: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:xampphtdocsdashboardwebservicefirebase_phpvendorguzzlehttpguzzlesrcHandlerCurlFactory.php:201 Stack trace: #0 C:xampphtdocsdashboardwebservicefirebase_phpvendorguzzlehttpguzzlesrcHandlerCurlFactory.php(537): GuzzleHttpHandlerCurlFactory::createRejection(Object(GuzzleHttpHandlerEasyHandle), Array) #1 C:xampphtdocsdashboardwebservicefirebase_phpvendorguzzlehttpguzzlesrcHandlerCurlFactory.php(152): GuzzleHttpHandlerCurlFactory::retryFailedRewind(Object(GuzzleHttpHandlerCurlHandler), Object(GuzzleHttpHandlerEasyHandle), Array) #2 C:xam in C:xampphtdocsdashboardwebservicefirebase_phpvendorkreaitfirebase-phpsrcFirebaseExceptionApiException.php on line 40

I also checked curl support and ssl from phpinfo

Advertisement

Answer

Because you don’t have enable curl.cainfo

enter image description here

You can add cainfo.pem to php.ini (http://curl.haxx.se/ca/cacert.pem)

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo=/etc/ssl/certs/cacert.pem
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement