Calls to an API fail with cURL error 60: SSL certificate problem: unable to get local issuer certificate. Laravel’s HTTP client lets you switch certificate checking off for one request, but you should only do that on a local machine.
Turn the check off for one request
use Illuminate\Support\Facades\Http;
$response = Http::withoutVerifying()->post('https://api.example.test/x', [
'amount' => 100,
]);
withoutVerifying() is shorthand for passing the Guzzle option verify => false. This is the same thing:
$response = Http::withOptions(['verify' => false])->post($url, $data);
Only the request built from that chain is affected. A plain Http::post() elsewhere still verifies the certificate.
Fix the cause: point at a CA bundle
Error 60 usually means PHP cannot find a CA bundle, or the server uses a private CA. Give Guzzle the file instead of turning checks off:
$response = Http::withOptions([
'verify' => storage_path('certs/company-ca.pem'),
])->post($url, $data);
You can also set curl.cainfo in php.ini to a current cacert.pem and leave your code alone.
Never ship the switch to production
Keep the decision in config and make it local-only:
public static function verifyOption(): bool|string
{
if ($bundle = config('services.gateway.ca_bundle')) {
return $bundle;
}
if (config('services.gateway.verify') === false && app()->environment('local', 'testing')) {
return false;
}
return true;
}
Http::withOptions(['verify' => GatewayClient::verifyOption()])->post($url, $fields);
A verify => false flag that leaks into production config is ignored, and a CA bundle always wins.
Tested on Laravel 10.x (PHP 8.1) and 12.x (PHP 8.3): the tests capture the options Guzzle receives and check each case above. Source: tests/laravel-verification/files/q1037.