Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL error 60: SSL certificate problem: self signed certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

I use Guzzle in my Laravel 7 project and XAMPP 7.4.5, I'm trying to make a GET to my local API localhost/events_platforma/view/users It works fine but when I'm trying to make a POST request to https://localhost/events_platforma/register it fails and gives out that cURL error and My API Are on SLIM.

I have added this file

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

But still, give out an error

like image 374
NgatungaEmily Avatar asked May 14 '26 22:05

NgatungaEmily


1 Answers

The quick solution for localhost is to turn off the certificate verification using options in guzzle of verify as false.

A quick small example below

use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'http://exmaple.org'
]);
$client->request('GET', '/', ['verify' => false]);

If you are using Http-client provided by laravel you can add guzzle options like this,

$response = Http::withOptions([
    'verify' => false,
])->get('http://example.org/');

NOTE:

Though even guzzle suggests to not using it, but if you are testing your own apis it can work.


Though you can simple add your certificates as per request just by providing path.

Mozilla provides a commonly used CA bundle which can be downloaded here (provided by the maintainer of cURL).

// Use a custom SSL certificate on disk.
$client->request('GET', '/', ['verify' => '/path/to/cacert.pem']);

Read more about certificates from https://curl.se/docs/sslcerts.html .
Read more about verify from guzzle docs verify

like image 72
bhucho Avatar answered May 16 '26 17:05

bhucho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!