SSL certificate problem: unable to get local issuer certificate in PHP OpenSSL
19K reputation · 02 Nov 2020, 12:51 UTC
PHP utilizes the OpenSSL extension to validate certificates during TLS handshakes for HTTPS requests. When the underlying library cannot locate a trusted root CA bundle, the system triggers a validation failure.
The php.ini configuration provides openssl.cafile and openssl.capath to define these trust stores. However, there is often a discrepancy between the default CA paths used by the operating system's OpenSSL installation and the paths recognized by the PHP runtime environment, particularly when deploying across different OS distributions.
Given these configuration requirements, what is the recommended method for ensuring consistent CA bundle resolution without hardcoding OS-specific paths? How does PHP prioritize the openssl.cafile directive relative to the system-level OpenSSL defaults?