PHP - SSL certificate error: unable to get local issuer certificate

PHP - SSL certificate error: unable to get local issuer certificate

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

PHP - SSL certificate error: unable to get local issuer certificate

When your PHP application attempts to reach out to a third-party API like Mandrill and encounters an SSL certificate problem: unable to get local issuer certificate exception, it is usually not a sign of a broken server. Instead, it indicates that the underlying library responsible for establishing the TLS connection cannot verify the identity of the remote server. In the specific scenario involving PHP 5.6.3 on Windows within XAMPP, this failure stems from how OpenSSL and cURL handle certificate bundles in non-Linux environments.

The error message originates from the cURL extension, which is often the default HTTP client used by PHP frameworks or standalone scripts when sending POST requests to RESTful APIs. If you are using a library like Mandrill_HttpError, it is likely wrapping an exception thrown by cURL after cURL itself failed during the handshake phase. The core issue is that cURL cannot find a trusted Certificate Authority (CA) bundle to validate the server's certificate chain.

A common misstep when facing this problem is modifying php.ini with the directive curl.cainfo = "C:\xampp\php\cacert.pem". While this configuration change is technically correct for Linux-based servers, it often fails on Windows if the path resolution or file permissions are not handled precisely. The source material notes that users have attempted to download cacert.pem from Curl's official documentation and placed it in the XAMPP directory, yet the error persists after a restart. This suggests that simply adding the line to php.ini might not be sufficient if the PHP binary running under Apache is not picking up the new configuration or if the file path contains characters that cause issues on Windows.

On Windows, paths in configuration files are case-sensitive and must match exactly, but more importantly, they should often be absolute paths without forward slashes to avoid ambiguity. Furthermore, PHP 5.6 has specific behaviors regarding how it loads these certificates. If you are using the php_openssl.dll extension alongside cURL, ensure that both extensions are loaded in your php.ini. Sometimes, even if curl.cainfo is set, the OpenSSL library itself might be relying on a system-wide certificate store that is misconfigured or missing entirely.

To resolve this without constantly editing configuration files, you can bypass the need for cacert.pem by using a different SSL verification approach. If your application allows it, switching the cURL handle to use CURLOPT_SSL_VERIFYPEER set to false is a quick fix for local testing, though never recommended for production environments due to the security risks of accepting any certificate. A more robust solution involves ensuring that the cacert.pem file is actually accessible via an absolute path in the php.ini.

Consider updating your php.ini entry to look like this:

curl.cainfo = "C:/xampp/php/cacert.pem"

Note the use of forward slashes in the Windows path, which PHP interprets correctly, and ensuring the file exists at that exact location. If you are using a custom php.ini located outside the XAMPP installation directory (common with Composer-managed projects), you must ensure this directive is present there as well, or define it via .env files if using Laravel's environment-specific configuration.

If you are working within a Laravel context, which often abstracts away these low-level details, the issue might be located in the service provider where the cURL handle is instantiated. You can programmatically set the certificate path when initializing the client:

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_CAINFO         => __DIR__ . '/cacert.pem',
]);

This approach guarantees that the application uses the specific certificate bundle provided, regardless of system-wide settings.

The trade-off here is complexity versus security. Relying on system certificates requires a perfectly tuned environment, whereas managing your own cacert.pem file gives you full control but adds maintenance overhead. If you are stuck with PHP 5.6.3, be aware that this version is end-of-life and lacks support for modern TLS protocols required by many current APIs. Upgrading to a supported PHP version alongside XAMPP or a native distribution will likely resolve underlying OpenSSL compatibility issues that older versions struggle with.

Our network