CodexBloom - Programming Q&A Platform

implementing PHP 8.2 and Guzzle HTTP client causing SSL connection failures

👀 Views: 46 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-19
PHP Guzzle SSL cURL HTTP

I tried several approaches but none seem to work. I'm writing unit tests and I'm getting frustrated with I'm working on a project and hit a roadblock. I'm experiencing SSL connection failures when making requests using Guzzle HTTP client in PHP 8.2. I have updated Guzzle to the latest version (7.5.0) and I'm using the following code to make a simple GET request: ```php require 'vendor/autoload.php'; use GuzzleHttp\Client; $client = new Client(); try { $response = $client->request('GET', 'https://example.com/api/data', [ 'verify' => true, ]); echo $response->getBody(); } catch (GuzzleHttp\Exception\GuzzleException $e) { echo 'Request failed: ' . $e->getMessage(); } ``` The scenario arises with the following behavior message: ``` Request failed: cURL behavior 60: SSL certificate question: unable to get local issuer certificate ``` I have tried setting the `verify` option to `false`, but that just skips the SSL verification and isn't a proper solution. I also confirmed that my PHP installation has the `openssl` extension enabled, and I have verified that the `cacert.pem` file is present and correctly referenced in my `php.ini` file: ``` [openssl] ; OpenSSL extension settings openssl.cafile="C:/path/to/cacert.pem" ``` After restarting the server and ensuring the paths are correct, I still encounter this scenario. I'm using XAMPP on Windows for development. Is there anything else I might be missing or any specific configurations I should check to resolve this SSL scenario? I'm working on a CLI tool that needs to handle this. What am I doing wrong? I'm on Ubuntu 20.04 using the latest version of Php. This is happening in both development and production on CentOS. My team is using Php for this application. I'm working with Php in a Docker container on Ubuntu 20.04.