---
title: "TLS works on the host but fails inside the container | Proofline"
description: "When TLS verification fails only inside a container, the image's trust store usually differs from the host's: it is missing, empty, or lacks a private CA."
url: https://proofline.sh/learn/container-image-ca-bundle-missing/
---

[Learning center](/learn/)

# TLS works on the host but fails inside the container

When TLS verification fails only inside a container, the image's trust store usually differs from the host's: it is missing, empty, or lacks a private CA. Read the trust store path inside the running container and compare it with the host's. The fix belongs in the image or the runtime's CA settings, and the dependency is probably fine.

Network outages The Proofline team November 23, 2026 5 min read

## 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](https://docs.openssl.org/3.0/man3/X509_STORE_CTX_get_error/) · [Go x509 verify](https://go.dev/src/crypto/x509/verify.go)

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 scratch` starts 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](https://docs.docker.com/build/building/base-images/)
-   **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: its `static` image documents that it contains ca-certificates, so a distroless image trusts public roots but not your private CA. [Distroless base and static contents](https://github.com/GoogleContainerTools/distroless/blob/main/base/README.md)
-   **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-certificates` adds `.crt` files from `/usr/local/share/ca-certificates` to `/etc/ssl/certs/ca-certificates.crt`, so the image build has to place the CA there and run it. [update-ca-certificates](https://manpages.debian.org/bookworm/ca-certificates/update-ca-certificates.8.en.html)

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](https://nodejs.org/api/cli.html) · [JSSE default truststore](https://docs.oracle.com/en/java/javase/21/security/java-secure-socket-extension-jsse-reference-guide.html)

## 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](https://docs.openssl.org/3.0/man7/openssl-env/) · [Go x509 root paths](https://go.dev/src/crypto/x509/root_linux.go) · [Go SystemCertPool](https://pkg.go.dev/crypto/x509) · [Python get\_default\_verify\_paths](https://docs.python.org/3/library/ssl.html)

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](https://kubernetes.io/docs/reference/kubectl/generated/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](https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/) · [Debug with an ephemeral container](https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/) · [/proc/pid/root](https://man7.org/linux/man-pages/man5/proc_pid_root.5.html)

```
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](https://docs.aws.amazon.com/cli/latest/reference/ecs/execute-command.html) · [docker container export](https://docs.docker.com/reference/cli/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](/learn/tls-unable-to-get-local-issuer/).

## 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](https://nodejs.org/api/cli.html)

Other layers can fail first. See the [hub for runtime dependency failures](/learn/runtime-dependency-failures/), and for a managed database whose CA changed, [RDS certificate authority rotation](/learn/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](https://curl.se/docs/sslcerts.html)

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

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Unable to get local issuer certificate: server chain or client trust?](/learn/tls-unable-to-get-local-issuer/)
    
    Network outages The Proofline team November 23, 2026 5 min read
    
-   ### [Database TLS failing after an Amazon RDS certificate authority change](/learn/rds-certificate-authority-rotation/)
    
    Network outages The Proofline team November 23, 2026 5 min read
