'Still same error display: cURL error 60: SSL certificate problem: unable to get local issuer certificate [closed]

I am using PHP version 8.1.2 and Laravel version 9.8.1. I fellow these steps from this https://www.scratchcode.io/curl-error-ssl-certificate-problem-unable-to-get-local-issuer-certificate/ link to resolved this issue. But still I got same error.

enter image description here

My code

$response = Http::timeout(30)->get('http://example.com/users');

I also made another project in laravel still I got same error



Solution 1:[1]

How to solve this problem:

  • download and extract cacert.pem following the instructions at https://curl.se/docs/caextract.html

  • save it on your filesystem somewhere (for example, XAMPP users might use C:\xampp\php\extras\ssl\cacert.pem)

  • in your php.ini, put this file location in the [curl] section (putting it in the [openssl] section is also a good idea):

Example:

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

[openssl]
openssl.cafile = "C:\xampp\php\extras\ssl\cacert.pem"
  • restart your webserver (e.g. Apache) and PHP FPM server if applicable

reference here

You could also remove SSL validation on localhost. Just need to add options to de GuzzleHttp client in the 'withOptions' method to disable verification.

 $options = ['verify'=>false];

To check if a local environment can do a simple if:

public function authApi(){

    $options = [];

    if (App::environment('local')) {
        $options = ['verify'=>false];
    }
    return Http::withBasicAuth($this->client_key, $this->client_key_secret)->withOptions($options);

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1