HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK
When upgrading from an older XAMPP installation to version 1.7.3, encountering a curl error like SSL3_GET_SERVER_CERTIFICATE:certificate verify failed is often more about environment drift than broken code. The specific error message you are seeing indicates that the SSL handshake initiated by cURL succeeded in establishing a connection, but the subsequent verification step failed because the local Certificate Authority (CA) bundle could not validate the server's certificate chain.
The fact that this worked on your previous XAMPP version is the critical clue. Upgrading XAMPP often involves replacing core binaries and libraries. In many cases, the new installation includes a fresh copy of OpenSSL and its associated CA certificates. If you are running cURL within PHP, it relies on the system's OpenSSL configuration to locate the trusted root certificates.
The most common misstep developers make when faced with this error is disabling certificate verification entirely. You might be tempted to add CURLOPT_SSL_VERIFYPEER => false or similar options in your code. While this technically resolves the immediate exception, it creates a severe security vulnerability. Disabling peer verification means your application accepts certificates from any domain, including malicious actors performing Man-in-the-Middle attacks. You should never disable verification unless you are explicitly testing against a self-signed certificate and understand the risks involved.
Instead of modifying every cURL request in your application to ignore errors, you need to ensure that your PHP environment is pointing to a valid and up-to-date CA bundle. The error details often hint at the root cause: the system cannot find the trusted roots or the path to them is incorrect.
To diagnose the issue, start by checking if PHP can locate the CA bundle. Run the following command in your terminal or via a PHP script:
php -r "echo ini_get('openssl.cafile');"
If this returns an empty string, it means OpenSSL is not configured to use a specific CA file. While modern systems often rely on system_default_paths, XAMPP bundles might not always pick these up correctly after an upgrade. You can explicitly set the path to the CA bundle using openssl.cafile in your php.ini:
openssl.cafile = /path/to/cacert.pem
Alternatively, you can use openssl.capath if you are using a directory of certificates rather than a single file. Ensure that the file you reference actually exists and contains valid CA certificates. A common source of these files is the package manager for your operating system (e.g., ca-certificates on Linux or the built-in certificate store on Windows), but XAMPP often ships with its own cacert.pem.
If upgrading XAMPP introduced a new version of OpenSSL that no longer trusts the old CA bundle, you may need to update the bundle itself. You can download the latest cacert.pem from official sources or use tools like update-ca-certificates (on Debian/Ubuntu) to refresh your local trust store.
Another possibility is that the server certificate chain provided by the remote site is incomplete or relies on a root certificate that has been deprecated or removed from the new OpenSSL version included in XAMPP 1.7.3. In such cases, simply updating the CA bundle to the latest version usually resolves the mismatch.
If you are integrating with Laravel or other frameworks where cURL is used extensively, ensure that your environment variables and php.ini settings are consistent across development and production. Sometimes developers copy code from a server where SSL works perfectly to a local machine with an outdated XAMPP setup without realizing that the underlying OpenSSL libraries differ significantly.
Finally, remember that while patching individual requests with cURL options is a quick fix, it masks the underlying configuration issue. The robust solution lies in aligning your local CA trust store with the current standards of the SSL/TLS protocol ecosystem. By updating your CA bundle and ensuring php.ini points to it correctly, you can maintain secure communication without compromising on verification logic.
For developers looking for a more streamlined way to handle HTTPS requests within their applications, utilizing dedicated libraries that manage SSL contexts internally can sometimes simplify these configuration headaches.