cURL error 60: SSL certificate problem
you can configure Guzzle, which Laravel uses under the hood for HTTP requests, to ignore SSL certificate verification for specific requests. Here's how you can do it:
-
Open your
app/Providers/AppServiceProvider.phpfile. -
Import the necessary classes at the top of the file:
use Illuminate\Support\Facades\Http;
use Illuminate\Support\ServiceProvider;
- Inside the
registermethod of theAppServiceProviderclass, add the following code to configure Guzzle to ignore SSL verification for specific requests:
public function register()
{
Http::macro('withoutSslVerification', function () {
return Http::withOptions([
'verify' => false,
]);
});
}
- Now, in your controller where you make the HTTP request, you can use the
withoutSslVerificationmacro before making the request:
use Illuminate\Support\Facades\Http;
// ...
$response = Http::withoutSslVerification()->get('https://domaine.fr/wp-json/wp/v2/');
$jsonData = $response->json();