[php-src] Issue #13601: Fallback from using Certificate Authority from Windows Certificate Store
| From: | Luc45 | Date: | Tue, 05 Mar 2024 16:57:36 +0000 |
| Subject: | [php-src] Issue #13601: Fallback from using Certificate Authority from Windows Certificate Store | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246513@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13601
Author: Luc45
### 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: https://github.com/Luc45/ci-playground/actions/runs/8159698661/job/22304587825
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](https://stackoverflow.com/questions/28858351/php-ssl-certificate-error-unable-to-get-local-issuer-certificate).
The [common solution](https://neurotechnics.com/blog/ssl-ca-bundles-for-curl-and-php/) for this
problem for Windows users is to download a trusted CA file (such as from Mozilla), and update
php.ini to use it:
- Download http://curl.haxx.se/ca/cacert.pem
- Point php.ini
openssl.cafile to the downloaded file
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.