php / php/php-src

curl: Fallback to using Certificate Authority from Windows Certificate Store

Open
#13,601 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: curl Feature
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

In PHP's current implementation, there is an inconsistency in how the language handles SSL/TLS certificate validation across different operating systems. This inconsistency primarily affects Windows users.

In this proof-of-concept, we can see the behavior clearly:

On Windows, the script does two requests:

  1. The first request without a CA file that fails and prints Request correctly failed without CA certificate (expected on Windows)
  2. A second request using the CA file from Mozilla that succeeds and prints Request succeeded with provided CA certificate

On Linux and Mac, it uses the O.S CA file, which prints Request succeeded without CA certificate (expected on Linux and macOS)

On Linux, it uses by default:

CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs

On Mac, it uses:

CAPath: /usr/local/etc/openssl@3/certs

On Windows, both are blank:

CAfile: (empty)
CApath: (empty)

Which means that PHP doesn't have a fallback Certificate Authority file to validate HTTPS requests, which leads to issues such as these. The common solution for this problem for Windows users is to download a trusted CA file (such as from Mozilla), and update php.ini to use it:

This is a sub-optimal solution as it increases complexity for the average John Doe that just wants to do a network request against a HTTPS URL.

I think PHP in Windows could fallback to accessing the Windows Certificate Store, or bundle a trusted CA file, although this might get outdated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository files or tests are named. Start by reviewing the linked Windows proof of concept and the current PHP HTTPS certificate-validation behavior, then define which fallback approach is supported; done means Windows requests validate trusted certificates without requiring a separately configured CA file.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.