Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL error 77: error setting certificate verify locations: CAfile

I am using Firebase php SDK link and working with laravel latest version on XAMMP server on windows 10 but when i try to use Firebase APi using above php SDK i get this error.i download .pem certificate manually but still not working

Error

Kreait \ Firebase \ Exception \ ApiException
cURL error 77: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Previous exceptions
cURL error 77: error setting certificate verify locations: CAfile: C:\xampp\apache\bin\curl-ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) (0)
like image 597
Anil meena Avatar asked Mar 17 '19 05:03

Anil meena


2 Answers

In your case, simply do this

Open your php.ini file and update this

;openssl.cafile=

with

openssl.cafile="C:\xampp\apache\bin\curl-ca-bundle.crt"

For others who might face this error, follow this:

It has to do with your cURL certification. Take these steps:

  1. Head over to http://curl.haxx.se/ca/cacert.pem. This link gets you (downloads) the latest cacert.pem file.

  2. Use this command on your terminal on the application you are currently working on so that you would know the exact PHP used in cases of multiple installations of PHP on your computer, php -i | grep 'Configuration File'. This shows you the exact location of the php.ini file for the current application you are running. For instance, mine is C:\php-7.4.11\php.ini. Note this location as we will use it soon.

  3. Go into this location C:\php-7.4.11 ie. the folder containing the php.ini file in my case, open "extras", open "ssl" (for clarity sake, mine looks like this C:\php-7.4.11\extras\ssl). In this folder, paste in the newly downloaded cacert.pem file from Step 1 above.

  4. Right-click on the cacert.pem file and unblock it from "Properties" as it could complain of coming from another computer. Still on this Properties section pop-up, copy the new file location link from the "Security" section (mine is C:\php-7.4.11\extras\ssl\cacert.pem ensure to copy yours). You can also copy this from the file browser header.

  5. Go to this location C:\php-7.4.11\php.ini (this is my php.ini location. Go to yours) and update the following 2 fields on your php.ini file.

    ;curl.cainfo =

    ;openssl.cafile=

with

curl.cainfo ="C:\php-7.4.11\extras\ssl\cacert.pem"

openssl.cafile="C:\php-7.4.11\extras\ssl\cacert.pem"
  1. Restart your xampp/wamp server. In my case, I also restart every other server running.

NB: You get cURL 60 error if curl.cainfo is not updated. And cURL 77 if openssl.cafile is not updated.

Also, do not forget to uncomment the ; before curl.cainfo and openssl.cafile.

Hope this helps someone.

like image 140
Max Ralph Avatar answered Nov 12 '22 23:11

Max Ralph


In my case using MAMP PRO I had this error :

CURL error: error setting certificate verify locations:
  CAfile: /Applications/MAMP/Library/OpenSSL/cert.pem
  CApath: none

The file /Applications/MAMP/Library/OpenSSL/cert.pem was a symlink to /Applications/MAMP/Library/OpenSSL/certs/cacert.pem

it appeared that the file was here but seems to be corrupted or out of date.

I downloaded the new one from here and replaced it. Then it worked again.

like image 45
Kaizoku Gambare Avatar answered Nov 12 '22 23:11

Kaizoku Gambare