Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Composer or PHP stream fails with certificate verify failed

Errorerror:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed

Short 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.

  • Applies to PHP 8.3, Composer 2
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 -vvv
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2php -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. 3The CA file is valid and current, and the error still appears on one machine only.Security software intercepts HTTPS and replaces the certificateFix

What does the error look like?

  • error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
  • SSL 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 diagnose

Confirmed by getcomposer.org

Did this fix it?

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

Did this fix it?

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 -vvv

2Fix

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 scanning

3Verify

Run the failed Composer command again.

composer diagnose

Confirmed by getcomposer.org

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.