Composer or PHP stream fails with certificate verify failed
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failedShort answer
PHP could not check the server's TLS certificate against a trusted CA file. Run composer diagnose -vvv to see where Composer looks for a CA bundle, put a current cacert.pem there or set openssl.cafile in the php.ini that is loaded, and restart. Do not disable TLS checks.
Fix it fast
1Find out which cause you have
Let Composer show which CA file or folder it checks. The first lines of the output name it.
composer diagnose -vvv2Match what you see, then jump to its fix
- 1
The first lines of composer diagnose -vvv say Checked CA file ... or Checked directory ... and the check fails.No CA bundle where Composer looks, or an outdated oneFix - 2
php -r prints an empty openssl.cafile even though you set it.openssl.cafile is set in a php.ini that PHP does not loadFix - 3
The CA file is valid and current, and the error still appears on one machine only.Security software intercepts HTTPS and replaces the certificateFix
- 1
What does the error look like?
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failedSSL certificate problem: unable to get local issuer certificate
Cause 1 of 3
No CA bundle where Composer looks, or an outdated one
1Check
Composer's troubleshooting page tells you to check that the root certificate store or CA bundle is up to date, and to look for the Checked CA file lines to see where Composer looks.
composer diagnose -vvv
php -r "var_dump(ini_get('openssl.cafile'), ini_get('openssl.capath'));"2Fix
Download a current cacert.pem from the cURL project and store it at the path Composer reports.
; php.ini
openssl.cafile = "C:\xampp\php\extras\ssl\cacert.pem"3Verify
Run the diagnose again, then the install that failed.
composer diagnoseConfirmed by getcomposer.org
Cause 2 of 3
openssl.cafile is set in a php.ini that PHP does not load
1Check
The setting only counts in the file that PHP loads. php --ini lists it.
php --ini
php -r "var_dump(ini_get('openssl.cafile'));"2Fix
Put openssl.cafile into the loaded php.ini file, or point capath at a hashed certificate folder, and run the command again.
; php.ini
openssl.cafile = "/etc/ssl/certs/ca-certificates.crt"3Verify
The ini value is now filled in.
php -r "var_dump(ini_get('openssl.cafile'));"Confirmed by php.net
Cause 3 of 3
Security software intercepts HTTPS and replaces the certificate
1Check
Composer's troubleshooting page says antivirus or firewall tools that scan HTTPS can stop Composer from working, for example Avast on Windows.
composer diagnose -vvv2Fix
Turn off HTTPS scanning in that tool to test. If it fixes the error, keep the scanning off for this traffic, or tell the vendor.
# Avast: Protection > Core Shields > Web Shield > uncheck Enable HTTPS scanning3Verify
Run the failed Composer command again.
composer diagnoseConfirmed by getcomposer.org
How do I stop it coming back?
- Refresh cacert.pem now and then, or use your OS's CA package on servers.
- Do not turn off certificate verification to make the error go away; it only hides the problem.
- Run composer diagnose after you install or upgrade PHP on a new machine.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
PHP cURL or Guzzle fails with SSL certificate error 60
curl: (60) SSL certificate problem: unable to get local issuer certificate
cURL cannot find a trusted CA file to check the server's certificate against.
3 causes, each with a fixBack end
PHP cURL cannot connect to a server that requires TLS 1.2
The handshake fails only against servers that require TLS 1.2 or newer
A server that requires TLS 1.2 rejects a client that offers an older version.
2 causes, each with a fixBack end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Apache returns 403 when a URL contains %3F
a request like /page%3Fname=test is refused while /page?name=test works
Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.
2 causes, each with a fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fix