Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL error 60: SSL certificate in Laravel 5.4

Full Error

RequestException in CurlFactory.php line 187: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Scenario

Before anyone points me to these two laracasts answers: https://laracasts.com/discuss/channels/general-discussion/curl-error-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate

https://laracasts.com/discuss/channels/general-discussion/curl-error-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate/replies/52954

I've already looked at them and that's why I'm here.

The problem I have is that now I have the cacert.pem file BUT it doesn't make sense where to put it, the answers indicate to place the file in my xampp directory and change my php.ini file but I'm not using xampp for anything, I'm using Laravel's artisan server to run my project.

If xampp is not in use, where should I place this file? Moreover, why would an accepted answer be to place it in my xampp directory? I dont understand.

My Exact Question

Where do I place the cacert.pem file to stop this error in laravel 5.4?

like image 728
Yasmin French Avatar asked Feb 07 '17 16:02

Yasmin French


People also ask

How do I fix curl 60 SSL certificate problem certificate has expired?

The only solution to this problem is to get your host to update the root certificate on your server. So, you need to contact your server host and ask them to insert a new cacert.

What is a curl Error 60?

Error “curl: (60) SSL certificate problem: unable to get local issuer certificate” can be seen when the SSL certificate on the server is not verified or properly configured.


2 Answers

A quick solution but insecure (not recommended).

Using cURL:

Set CURLOPT_SSL_VERIYPEER to false 

Using Guzzle: Set verify to false, for example

$client->request('GET', 'https://somewebsite.com', ['verify' => false]); 
like image 35
Jeffrey Avatar answered Sep 25 '22 20:09

Jeffrey


Do not ever modify files in the vendor/ folder. Ever. They can and will be overwritten on the next composer update you run.

Here is my Solution for WampServer

I am using PHP 7.1.9 for my WampServer, so change 7.1.9 in the example below to the version number you are currently using.

  1. Download this file: http://curl.haxx.se/ca/cacert.pem
  2. Place this file in the C:\wamp64\bin\php\php7.1.9 folder
  3. Open php.iniand find this line:

;curl.cainfo

Change it to:

curl.cainfo = "C:\wamp64\bin\php\php7.1.9\cacert.pem"

Make sure you remove the semicolon at the beginning of the line.

Save changes to php.ini, restart WampServer, and you're good to go!

like image 117
kjdion84 Avatar answered Sep 24 '22 20:09

kjdion84