PHP: How to resolve the “cURL error 60” error

Hey guys.

Today I was studying and developing an application tests that must connect with a Realtime Database of Google Firebase. To integrate my PHP project with Firebase, I added the firebase-php library  (Available at: https://github.com/kreait/firebase-php ).

Well then. My project is being “executed” in a local environment (WAMPP) and as soon as I tried to recover the data previously registered in the Firebase database, I came across the following error:

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)

Obviously, an error in the SSL certificate.

Researching about this error, I realized that it was necessary to have a ” cert_file ” (certificate file) on my machine and that the  php  should point to it. First of all, it is necessary to check which “cert_file” the php is pointing to. To do this, run the following command:

1
var_dump(openssl_get_cert_locations());

This command will generate something like this:

1
2
3
4
5
6
7
8
9
array (size=8)
  'default_cert_file' => string 'C:\Program Files\Common Files\SSL/cert.pem' (length=42)
  'default_cert_file_env' => string 'SSL_CERT_FILE' (length=13)
  'default_cert_dir' => string 'C:\Program Files\Common Files\SSL/certs' (length=39)
  'default_cert_dir_env' => string 'SSL_CERT_DIR' (length=12)
  'default_private_dir' => string 'C:\Program Files\Common Files\SSL/private' (length=41)
  'default_default_cert_area' => string 'C:\Program Files\Common Files\SSL' (length=33)
  'ini_cafile' => string '' (length=0)
  'ini_capath' => string '' (length=0)

Note that, in my case, the position “default_cert_file” is pointing to the path:  C: \ Program Files \ Common Files \ SSL / cert.pem

I happened to go to the “ Common Files ” folder and it didn’t have the SSL  sub-folder  (consequently I didn’t have the cert.pem file  ). So, I created the SSL folder and then I went to  https://curl.haxx.se/ca/cacert.pem  and downloaded the certificate file. After downloading, I renamed the file from “ cacert.pem ” to “ cert.pem ” and moved it into my SSL folder .

This way it should already work (maybe for you it already did) , but the error persisted, so I opened my php.ini  file  , looked for the line “curl.cainfo”, “uncommented” the line (removing the “;”) and I put the absolute path for my “cert_file”. Staying like this:

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo ="C:\Program Files\Common Files\SSL\cert.pem"

That done, I saved the php.ini file and restarted my WAMP. Ready! The fatal error  no longer happens and the data in my Realtime Database is returned normally.

I hope to help you with this tip.

Hugs !!!

He has a degree in Information Systems and a postgraduate degree in Database Systems. He works as a professor of technical and technological education at the Federal Institute of Education, Science and Technology of São Paulo (IFSP), teaching disciplines in the areas of programming, database, project development and software engineering.

Deixar um comentário

motorcycle fairings for sale Wholesale Honda Fairing Kits cheap suzuki fairings cheap ABS Fairings cheap Kawasaki fairings cheap yamaha fairings
cheap trx home cheap trx trainer cheap trx training TRX Suspension Training trx pro4 trx home2 trxhometrainer.com