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