What the failure looks like#
The same call works from the host, a laptop or another service, and fails from one image. The error is a trust failure: unable to get local issuer certificate from OpenSSL-based clients, x509: certificate signed by unknown authority from Go, or, when Go finds no roots at all, x509: failed to load system roots and no roots provided. OpenSSL verify error codes · Go x509 verify
A container has its own filesystem. A trust store on the host, or a private CA your device management installed there, does not reach a process in an image unless the image includes it or something mounts it in.
Three ways the image's store falls short#
- No store at all. An image built
FROM scratchstarts with nothing: the next instruction becomes the first filesystem layer. A static binary copied into it has no CA file unless the Dockerfile copies one in. Docker scratch base image - A minimal base without the package. Some slim and minimal images do not install
ca-certificates, so check the image instead of assuming. Distroless differs here: itsstaticimage documents that it contains ca-certificates, so a distroless image trusts public roots but not your private CA. Distroless base and static contents - A private CA installed on hosts only. Internal dependencies signed by a company CA verify on hosts that trust that CA and fail in an image that ships only public roots. On Debian-based images,
update-ca-certificatesadds.crtfiles from/usr/local/share/ca-certificatesto/etc/ssl/certs/ca-certificates.crt, so the image build has to place the CA there and run it. update-ca-certificates
Language runtimes add a fourth twist. Node.js can use a bundled snapshot of the Mozilla store chosen at build time, and adds certificates from the file named in NODE_EXTRA_CA_CERTS, read once at startup. Java uses its own cacerts truststore unless javax.net.ssl.trustStore names another. A private CA added to the OS store can still be missing for these runtimes. Node.js CA store options · JSSE default truststore
Where each runtime looks#
OpenSSL reads a default file and directory set at build time, and SSL_CERT_FILE and SSL_CERT_DIR override them. Go on Linux tries a list of files, including /etc/ssl/certs/ca-certificates.crt (Debian and Ubuntu), /etc/pki/tls/certs/ca-bundle.crt (Fedora and RHEL) and /etc/ssl/cert.pem (Alpine), stopping at the first it finds, and honours the same two variables. Python's ssl.get_default_verify_paths() prints the paths OpenSSL will use. OpenSSL environment variables · Go x509 root paths · Go SystemCertPool · Python get_default_verify_paths
A variable that points at a file the image does not contain is as bad as no store. Check the environment along with the files.
Read the trust store inside the container#
On Kubernetes, if the image has a shell and basic tools, read the paths and the environment directly. These commands only read. kubectl exec
kubectl exec -n NAMESPACE POD -c CONTAINER -- sh -c '
env | grep -E "^(SSL_CERT_FILE|SSL_CERT_DIR|NODE_EXTRA_CA_CERTS)="
ls -l /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt /etc/ssl/cert.pem 2>&1
grep -c "BEGIN CERTIFICATE" /etc/ssl/certs/ca-certificates.crt 2>&1'
A missing file, a zero count or a variable pointing at a missing path explains the failure. To check for a specific private CA, search the bundle for its subject, or compare its fingerprint with the CA file your platform team publishes.
A distroless or scratch image has no shell. Attach an ephemeral debug container that targets the application container's process namespace, then read the application's filesystem through /proc/1/root. Adding an ephemeral container changes the pod: it cannot be removed once added, and it needs the pods/ephemeralcontainers permission. Reading another process's root also requires ptrace read access to it. Ephemeral containers · Debug with an ephemeral container · /proc/pid/root
kubectl debug -it -n NAMESPACE POD --image=busybox:1.36 --target=CONTAINER -- \
sh -c 'ls -l /proc/1/root/etc/ssl/certs/ 2>&1 | head'
On ECS, aws ecs execute-command runs a command inside a task started with execute command enabled, and the same ls and grep apply. Without access to a running task, inspect the image itself: create a container without starting it, list its files, then remove it. execute-command · docker container export
cid=$(docker create IMAGE)
docker export "$cid" | tar -tf - | grep -E 'ssl/cert|ca-certificates|pki/tls'
docker rm "$cid"
Read the result#
| Inside the container | Points to |
|---|---|
| No CA file at any known path | Image has no store |
| File present, public roots only | Private CA not in the image |
| Variable points at a missing file | Broken runtime setting |
| File complete, Node or Java fails | Runtime uses its own store |
| Same store as the host | Not the image; compare chains |
If the container's store matches the host's and the call still fails, the chain the server sends is the next suspect: unable to get local issuer certificate.
A worked example with two outcomes#
This example is illustrative. The orders team moves its Go service from a Debian base to FROM scratch to shrink the image. After the deploy, calls to payments.example.com fail.
In the first outcome, the log says x509: failed to load system roots and no roots provided. The image listing shows no file under etc/ssl at all. The build stage had the bundle, but the final stage copies only the binary. Copying the bundle into the final image fixes it, and payments needed no change.
In the second outcome, the team had switched to distroless static instead. Public calls work, but calls to ledger.example.internal fail with x509: certificate signed by unknown authority. The store holds only public roots; the hosts trust Example Internal Root 2 through device management. Adding that root to the image, or pointing SSL_CERT_DIR at a mounted directory that contains it, fixes it.
Limits#
Reading files proves what the store contains, not what the process loaded. A runtime that read its store at startup keeps that copy; Node.js reads NODE_EXTRA_CA_CERTS only when the process launches. A client library can also pass its own CA file, which overrides every default, so read the service's TLS configuration as well. Node.js NODE_EXTRA_CA_CERTS
Other layers can fail first. See the hub for runtime dependency failures, and for a managed database whose CA changed, RDS certificate authority rotation.
Questions#
Why does curl in the container work when my app fails?
curl and your app may use different stores. curl can be built with its own CA bundle path and honours CURL_CA_BUNDLE, SSL_CERT_FILE and SSL_CERT_DIR; Node.js and Java may use their own stores. Compare the paths each one uses. curl CA certificates
Can I mount the host's trust store into the container?
Mounting a CA directory and pointing SSL_CERT_DIR or SSL_CERT_FILE at it works for OpenSSL and Go. It couples the image to each host's configuration, so a store built into the image is easier to reason about.
Does a sidecar or service mesh change this?
If a mesh proxy originates TLS for the application, the proxy's trust settings apply, not the application image's. Check which process opens the TLS connection before reading its store.