Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Laravel cURL SSL certificate problem: unable to get local issuer certificate

I my project written in Laravel I have method that get number value from server:

public static function getAddressApiBalance()
    {
        try {
            $uri = "https://btczexplorer.blockhub.info/ext/getbalance/t1ZYiG4R4n5gTgUKZRgVpKPzG5FYQXpEqga";

            $response = Http::get($uri);

            return $response;
...

And when I call this code I get error in my browser:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
like image 442
Robert Avatar asked Sep 17 '25 07:09

Robert


2 Answers

You can disable ssl verification (not recommended!, but quick and easy for dev) :

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

or with guzzle :

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

or you can download a cacert.pem file :

https://curl.haxx.se/ca/cacert.pem

and edit your php ini with the path of cacert :

openssl.cafile=/etc/ssl/cacert.pem
like image 186
neoteknic Avatar answered Sep 18 '25 22:09

neoteknic


\Illuminate\Support\Facades\Http::withOptions([]) accept guzzlet http options https://docs.guzzlephp.org/en/stable/request-options.html#verify

like image 21
blacksheep Avatar answered Sep 18 '25 21:09

blacksheep