Reputation: 17
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 GuzzleHttp\Exception\ConnectException: 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:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:200 Stack trace: #0 C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(155): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(105): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(Guz in C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\kreait\firebase-php\src\Firebase\Exception\ApiException.php on line 40
my php code is so simple:
<?php
require_once './vendor/autoload.php';
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$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 GuzzleHttp\Exception\RequestException: 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:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:201 Stack trace: #0 C:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(537): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(152): GuzzleHttp\Handler\CurlFactory::retryFailedRewind(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Array) #2 C:\xam in C:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\kreait\firebase-php\src\Firebase\Exception\ApiException.php on line 40
I also checked curl support and ssl from phpinfo
Upvotes: 0
Views: 4161
Reputation: 375
While working on my local machine, this is how I got around this, download the cacert.pem file from http://curl.haxx.se/ca/cacert.pem
copy the file to the php location i.e. if using Wamp
C:\wamp64\bin\php\cacert.pem
or if using Xampp
C:\xampp\php\cacert.pem
****Please note that use the paths in your environment.
Then if using Wamp edit the php.ini file in the apache folder i.e.
C:\wamp64\bin\apache\apache2.4.39\bin
edit the lines:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\wamp64\bin\php\cacert.pem"
Or using Xampp
C:\xampp\php
edit the lines:
curl.cainfo = "C:\xampp\php\cacert.pem"
Then restart your Wamp or Xampp Services, that should do the trick.
Upvotes: 0
Reputation: 32
On my local, I have only changed DNS to 8.8.8.8 to solve it
Upvotes: 0
Reputation: 32
Because you don't have enable curl.cainfo
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
Upvotes: 0
Reputation: 30595
According to the curl(1)
manual page, an error code 35 is an SSL handshake failure:
EXIT CODES ... 35 SSL connect error. The SSL handshaking failed.
You can try temporarily disabling the SSL certificate verification to see if that fixes the issue.
curl_setopt($handle, CURLOPT_VERIFYPEER, 0); // ***JUST A TEST! DO __NOT__ PUSH THIS TO PRODUCTION!***
If that does fix the issue, the reason is probably one of the two most common SSL handshake failures:
If that does NOT fix the issue, the reason is probably:
Upvotes: 0