Skip to content

Fix PHP TLS cert verification in prod image - #953

Merged
dunglas merged 1 commit into
dunglas:mainfrom
julien-guillon:fix/php-tls-cert-verification
Jun 26, 2026
Merged

Fix PHP TLS cert verification in prod image#953
dunglas merged 1 commit into
dunglas:mainfrom
julien-guillon:fix/php-tls-cert-verification

Conversation

@julien-guillon

Copy link
Copy Markdown
Contributor

Native PHP HTTPS streams failed in the production image with certificate verify failed, notably when using fopen() on remote HTTPS files.

Reproduction

docker build --target frankenphp_prod -t verify-prod .
docker run --rm verify-prod php -r 'var_dump(fopen("https://www.google.com", "r"));'
# Symfony v8.1.0 (env: prod, debug: false)
# PHP app ready!
# PHP Warning:  fopen(): SSL operation failed with code 1. OpenSSL Error messages:
# error:0A000086:SSL routines::certificate verify failed in Command line code on line 1
# PHP Warning:  fopen(): Failed to enable crypto in Command line code on line 1
# PHP Warning:  fopen(https://www.google.com): Failed to open stream: operation failed in Command line code on line 1
# bool(false)

The image contains the CA bundle at /etc/ssl/certs/ca-certificates.crt but OpenSSL looks by default for /usr/lib/ssl/cert.pem which is missing in the slim Debian image.

Fix

Set SSL_CERT_FILE so OpenSSL and native PHP streams use the CA bundle already present in the image:

ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

@dunglas
dunglas merged commit 4999b3f into dunglas:main Jun 26, 2026
2 checks passed
@dunglas

dunglas commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants