Laravel 5 Socialite - cURL error 77: error setting certificate verify locations
Asked Answered
T

24

43

I am using socialite in Laravel 5 to setup facebook login. I followed the instructions carefully until I got stuck with the following error

cURL error 60: SSL certificate problem: unable to get local issuer certificate

so I found the this answer to fix it which indeed passed but then I got this error

cURL error 77: error setting certificate verify locations:
CAfile: /Applications/XAMPP/xamppfiles/cacert.pem
CApath: none

Any ideas what's the cause of this error?! and how to fix it?!

Tying answered 14/5, 2015 at 15:10 Comment(5)
Are you using a real SSL certificate or a self certified certificate? Does the /Applications/XAMPP/xamppfiles/cacert.pem file exist?Teresiateresina
@Teresiateresina I downloaded the file as mentiond in the answer attached so it's the in the path /Applications/Xampp/xamppfilesTying
you need to put an absolute path not a relative pathBasham
Careful if open_basedir is set, that it includes the directory where cacert.pem is located.Coper
Are you sure the name of the file is cacert.pem or cacert.perm? Check the extensions correctly and make sure that's what you have in your environment's certificate path, usually locatedin the php.ini file at curl.cainfo ="C:/wamp64/bin/php/php7.2.10/extras/ssl/cacert.pem"Practice
D
40

I got stuck on this problem as well. It turned out that I had the path to my certificate set incorrectly in my php.ini file. Forgot the .txt extension.

What I had:

curl.cainfo = "C:\xampp\php\cacert.pem"

What I changed it to:

curl.cainfo = "C:\xampp\php\cacert.pem.txt"

Hope this helps.

Dituri answered 19/5, 2015 at 0:16 Comment(6)
Not working still. My file is called just "cacert.pem" no ".txt" extension.Tying
@omarsafwany, perhaps your file extension may have been set to hidden. The certificate is basically a text file so the .txt extension should be added along with its absolute path. Restart your apache server too for these changes to take effect.Teem
+ may be try moving .pem file in 'bin/php/version-X.X/ext' folder.Ileostomy
For me it was a typical PEBKAC - while I configured (read: copy&pasted) "C:\xampp\...", the actual Xampp installation was in "C:\Program Files\xampp\...".Calque
I must agree that the downloaded pem file was converted to a file with a .txt extension. Mine surprisingly worked when I changed it to cacert.pem.txt. I noticed this already that the file type is saved in text format but I was hesitant to use the .txt extension but eventually gave it a try and it worked.Inhambane
In my case it's the relative path. You must specify the full path. In case you need it relative from the coding, you can determine the path dynamically using dirname(__FILE__).'/../cacert.pem' for example.Ehrenburg
B
31

Add cacert.pem file from https://curl.haxx.se/ca/cacert.pem in c:\xampp\php\cacert.pem

Change setting in php.ini file:

curl.cainfo = "C:\xampp\php\cacert.pem

Blackmarketeer answered 29/11, 2016 at 9:10 Comment(3)
Helped me to make GuzzleHttp php package work. Thanks mate.Templet
Had to set openssl.cafile in php.ini to the same thing as well, but this worked for me.Alcaraz
Not working, I have litteral than you write here.Selina
G
25

My error is:

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)


This works well for me:

  1. Download the certificate from: https://curl.haxx.se/ca/cacert.pem
  2. Rename the cacert.pem file into curl-ca-bundle.crt
  3. Copy the file into path/to/xampp/apache/bin
  4. Restart apache
Golgotha answered 20/3, 2019 at 14:58 Comment(1)
Thank you. The "rename" saved my day. God Bless YouSonnysonobuoy
M
10

I experienced some issues following instructions in regards to error 77.

On Windows 7, depending on your security settings - the file downloaded may be blocked. See screenshot:

Windows 7 File Properties

Once I unblocked the file and ensured proper user access rights, I also had to put the file in the following location:

C:\xampp\apache\bin\cacert.pem.txt

In addition to changing php.ini per the other posts on this issue.

curl.cainfo="C:\xampp\php\cacert.pem.txt"

After completing the above steps, restarting Apache via the XAMPP Control Panel, the error was resolved.

Mahdi answered 24/4, 2019 at 14:11 Comment(0)
B
8
  1. Save this certificate (https://curl.haxx.se/ca/cacert.pem) as cacert.pem.txt in C:\xampp\php
  2. Add to php.ini:

    curl.cainfo = "C:\xampp\php\cacert.pem.txt"
    
  3. Don't forget to restart XAMPP (it won't work until it restarts)

Then it works fine!

Barna answered 3/5, 2016 at 18:19 Comment(1)
Worked for me although I had to set my path accurately like "C:\wamp64\bin\php\extras\cacert.perm" or "C:\wamp64\bin\php\php7.2.1\extras\cacert.perm" . Also be sure to restart your web server after making changes to your php ini file.Practice
M
8
  1. Download from (https://curl.haxx.se/ca/cacert.pem)
  2. Change the name 'cacert.pem' to 'curl-ca-bundle.crt'
    (after that, move it to the path 'C:\xampp\apache\bin')
  3. In 'php.ini', remove ';' in the following line: curl.cainfo="C:\xampp\apache\bin\curl-ca-bundle.crt"

That works for me.

Midwinter answered 13/3, 2019 at 5:5 Comment(1)
you should need to mention that the file shall be placed in " C:\xampp\apache\bin " pathThenceforth
S
6

Checkout double quote on php.ini file: if you copied and past from the Web maybe you got wrong double quote:

”C:\xampp\php\cacert.pem.txt”

instead of

"C:\xampp\php\cacert.pem.txt"

Sheaves answered 25/8, 2016 at 10:22 Comment(3)
Thank you, if you don't mention this I'd probably spend hours trying to figured out.Augmented
Oh man, this worked for me too - my last quote appears was incorrect. I don't believe I would have figured this out. You are a life saver - THANKS!Polished
YES!!!! This one! Damn :)Howlyn
R
4

In your php.ini file, you should also update your

;openssl.cafile 

with the same cacert.pem link you used in updating your

;curl.cainfo

Have a look at mine before and after

;curl.cainfo =

;openssl.cafile=

to

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

openssl.cafile="C:\php-7.4.11\extras\ssl\cacert.pem"

this fixes the cURL 60 error

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

while

openssl.cafile="C:\php-7.4.11\extras\ssl\cacert.pem" 

fixes the cURL 77 error.

Have fun!

NB: Do not forget to restart your server before trying it out.

For those who wish to find their php.ini file, use this command after you cd into your application

php -i | grep 'Configuration File'
Respite answered 5/2, 2021 at 13:30 Comment(0)
W
3

For windows

I had same problem after i updated php on window 2008. Suddenly all my php codes stopped working. What i did, i opned php.ini then i found a line

;curl.cainfo =

and i changed to

curl.cainfo = "C:\Program Files (x86)\PHP\v7.0\cacert.pem" (remember to remove ; before curl.cainfo)

and everything went to normal. What you need is to download a cert file cert.pem and place it anywhere on your server and change the line as i did in php.ini

Warhol answered 23/10, 2017 at 7:19 Comment(0)
T
2

You need to replace the existing certificate with the other one here. After that:

  • Extract and add it to xampp\php\ext
  • Open xampp\php\php.ini
  • Add this line curl.cainfo='location from the first step' to the end of the file.
  • Restart and it should be working now.

This is the source link.

Tying answered 8/11, 2016 at 11:38 Comment(0)
T
2

This same problem with me in php version 8.0.3 on windows : Solution was I had to uncomment and set openssl.capath=path of certs in php.ini file.

I already set openssl.cafile so it was not throwing error for that but oepnssl.capath was not set sot error was there.

openssl.cafile="C:\Users\Akta\Softwares\php-8.0.3-nts-Win32-vs16-x64\extras\ssl\demoCA\cacert.pem"

openssl.capath="C:\Users\Akta\Softwares\php-8.0.3-nts-Win32-vs16-x64\extras\ssl\demoCA\certs"

Tobietobin answered 16/3, 2021 at 9:20 Comment(0)
B
1

ULTIMATE SOLUTION THAT WORKS 2022, 2023, 2024

  1. Download from [(https://curl.haxx.se/ca/cacert.pem)][1]
  2. Download the 'cacert.pem' twice
  3. Change the name of the second downloaded 'cacert.pem' to 'cacert.crt'
  4. Place both files in C:/wamp64/bin/php/php7.4.26/extras/ssl/ (your php version may different, so choose that directory.)

  1. In your php.ini file from the wamp sever,

  2. Uncomment ;curl.cainfo & ;openssl.cafile, be removing the semicolon before it.

  3. Make changes as shown below: curl.cainfo ="C:/wamp64/bin/php/php7.4.26/extras/ssl/cacert.pem"

    openssl.cafile="C:/wamp64/bin/php/php7.4.26/extras/ssl/cacert.crt"

  4. Restart wamp

  5. It works like merlin magic (-_-)

Boettcher answered 14/5, 2015 at 15:10 Comment(0)
W
1

I read every thread I could find and this one provided the missing piece.

Background: I encountered this issue will trying to get Drupal 8 to check for available updates on a fresh development environment (wamp based).

  1. Get a copy of the Certificate data from Mozilla, it can be found here: https://curl.haxx.se/ca/cacert.pem If you want to know more about what this is read this: https://serverfault.com/questions/241046/what-is-the-cacert-pem-and-for-what-to-use-that
  2. Save the file as "cacert.pem.txt" not as "cacert.pem" This was the missing piece, thanks LyleK!. I have no clue why but you must have the .txt extension on the end or it does not work.
  3. Explicitly add the path to the location of the "cacert.pem.txt" file to your php.ini

Example:

[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
curl.cainfo = "C:\wamp\custom\cacert.pem.txt"

If you are using a wamp stack restart it. You should be good to go.

Weep answered 8/2, 2016 at 16:41 Comment(0)
R
1

First, you need to download your "curl.cainfo" file then you need to locate it to C:\xampp\php\cacert.pem.txt.

Second, you need to open your php.ini file in Xampp and copy this =>

curl.cainfo = C:\xampp\php\cacert.pem.txt anywhere you want.

Third please restart your Apache Server refresh your localhost page and that should work fine.

Rexford answered 6/8, 2016 at 15:59 Comment(0)
G
1

If anyone is running Windows with Plesk and they get this error.

You must ensure that the curl.cainfo path is inside the Plesk PHP directory otherwise you will get the error above even with the fix.

curl.cainfo = "C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP55\extras\ssl\cacert.pem.txt"

Fixed for me. Hope this helps someone, someday, somewhere.

Gorilla answered 19/5, 2017 at 15:42 Comment(1)
And if you use Plesk in a shared host without access to the PHP directory, you can only set the curl option CURLOPT_CAINFO directly before each use.Propagandize
S
1

I've tried @mahesh-singh-chouhan, @omarsafwany, @LyleK solutions. but get same error repeatedly.

After that, I update php.ini file without double quotes & with .pem extension & I'm succeed to get desired result with below code.

curl.cainfo=E:\Xampp-5.6.3\php\ext\cacert.pem

I've also attached Screenshot.

Please first try above users suggestions, If failed also use this.

Thanks for solutions It creates way for me @mahesh-singh-chouhan, @omarsafwany, @LyleK

enter image description here

Sylvanus answered 18/10, 2017 at 15:4 Comment(0)
B
1

you did not read the error carefully, now read it carefully

cURL error 77: error setting certificate verify locations: CAfile: D:\XAMPP\apache\bin\curl-ca-bundle.crt CApath: none (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

it means you are missing a file called curl-ca-bundle.crt to verify certificate locations, so you just need to put this(curl-ca-bundle.crt) file into your XAMPP\apache\bin\ folder and everything is fine error 77 has gone.

curl-ca-bundle.crt, to download the file you can use this link https://github.com/nirmalkumar98/nk

Boxhaul answered 17/3, 2019 at 3:18 Comment(1)
Man, you're awesome! I had dive many many resolutions and hadn't noticed: the location is.. Thank you, anyway :-)Oblivion
V
0

I had the same issue and i tried every solution mentioned here and on other posts but none of them worked. I tried
1) Setting proper file rights ( didn't work )
2) Changing file extension ( didn't work)


then i moved the cacert.pem file inside php/ directory in xampp and restarted it, it worked. Hope it helps someone.

Vicky answered 12/5, 2016 at 6:2 Comment(0)
B
0

this worked for me

curl.cainfo = "C:\xampp\php\cacert.pem.txt"

hope it helps some one :)

Barrelchested answered 27/8, 2016 at 17:11 Comment(1)
If this code answers the question, consider adding adding some text explaining the code in your answer. This way, you are far more likely to get more upvotes — and help the questioner learn something new.Deliladelilah
J
0

It seems you forgot to add quote for the file path. I was got the same error (77), that was because i forgot to add quotes. I solved the problem by adding that. ex: "C:\AppServ\php\cacert.pem"

Jungjungfrau answered 4/12, 2018 at 7:28 Comment(0)
T
0

i had this problem in windows 2012

i had a virtual dedicated server that host for laravel

then i had this error and

  • download that file from here
  • put in my extras folder in php 7.2
  • in my php.ini file find this line

    [curl]

    ; A default value for the CURLOPT_CAINFO option. This is required to be an

    ; absolute path. curl.cainfo = extras/ssl/cacert.pem

  • i paste my download file into php file sth like this:

curl.cainfo = "C:\Program Files (x86)\PHP\v7.2\extras\ssl\cacert.pem" cacert error rest api call curl php

  • then save php.ini
  • then restart my iis or just website

restart your iis windows 2012 cacert 77 error laravel php

in my case i just restart my website

Temblor answered 24/9, 2019 at 15:34 Comment(0)
F
0

For solve this error use this code :

 $client = new Client(['verify' => false ]);

And use this $client like this in your code:

   $headers = [
            'Authorization' => 'Bearer ' . $token,
            'Accept' => 'application/json',
            RequestOptions::BODY => ' any code for your body ',
        ];

        $response = $client->request('POST', 'bar', [
            'headers' => $headers
        ]);

        $response = $response->getBody()->getContents();

        return $response;
Fabaceous answered 18/9, 2020 at 21:25 Comment(0)
B
-1

i had the same problem. you have to open the file .pem or pem.txt with a simple editor (bloc-note) and past the (https://curl.haxx.se/ca/cacert.pem) in your file. you have to reload apache.

Burgundy answered 14/4, 2017 at 9:25 Comment(0)
W
-5

If it is related to git:

git config --global http.sslverify "false"

will solve the problem.

Wertz answered 25/2, 2016 at 14:45 Comment(2)
Down voted this response, disabling SSL is never a good solution.Nerissanerita
It is not disabling SSL, only certificate validation. Still not a good solution though!Carleton

© 2022 - 2024 — McMap. All rights reserved.