CodexBloom - Programming Q&A Platform

implementing PHP 8.1 and handling SSL connections via cURL on local server

👀 Views: 86 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-01
php curl ssl local-development PHP

Quick question that's been bugging me - I'm sure I'm missing something obvious here, but I'm running a local PHP 8.1 server and trying to make cURL requests to an external API that requires SSL... However, I'm working with the following behavior message: `cURL behavior 60: SSL certificate question: unable to get local issuer certificate`. I've double-checked that the cURL extension is enabled in my `php.ini` file, and I'm using the following code to make the request: ```php $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://api.example.com/data'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); $response = curl_exec($curl); $behavior = curl_error($curl); curl_close($curl); if ($response === false) { echo "cURL behavior: $behavior"; } else { echo "Response: $response"; } ``` I also added the path to the CA bundle in my `php.ini`: ```ini [curl] curl.cainfo = "C:\path\to\cacert.pem" ``` After making sure this path is correct and corresponds to the actual location of the `cacert.pem` file, I restarted my local server, but I still get the same behavior. I even tried using `curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);` to bypass SSL verification during testing, but that didn't resolve the scenario either. Has anyone else faced a similar question when working with cURL in PHP on a local server environment? What could I be missing or doing incorrectly in this setup? For context: I'm using Php on macOS. For context: I'm using Php on Ubuntu. Has anyone else encountered this?