Error fix · Developer errors

CA Certificates Missing in Docker Containers: x509 and SSL Errors Fixed

HTTPS calls failing inside Docker with x509 unknown authority or curl error 77? Install or copy ca-certificates for Debian, Alpine, scratch and distroless.

Error messagex509: certificate signed by unknown authority

By SiteDownCheck Editorial · Updated November 18, 2026 · 4 min read

Slim and minimal container images often ship without a trust store: the bundle of root certificate authority certificates used to verify HTTPS servers. The app runs fine locally and then fails in the container the first time it calls an HTTPS API. The error depends on the language:

Go:      Get "https://api.example.com": tls: failed to verify certificate: x509: certificate signed by unknown authority
curl:    curl: (77) error setting certificate verify locations: CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs
curl:    curl: (60) SSL certificate problem: unable to get local issuer certificate
Python:  ssl.SSLCertVerificationError: certificate verify failed: unable to get local issuer certificate
Node:    Error: unable to get local issuer certificate

The website's certificate is usually fine. The container simply has no list of roots to compare it with. Always test the remote server first with the SSL Checker so you do not chase a container issue when the real problem is an incomplete chain on the server (see incomplete certificate chain).

Step 1: confirm the trust store is missing

docker run --rm --entrypoint sh your-image -c 'ls -l /etc/ssl/certs | head; ls -l /etc/ssl/certs/ca-certificates.crt'

If /etc/ssl/certs is empty or the bundle file does not exist, you have found it. Images based on scratch and some distroless or -slim variants have little or nothing there. If the shell is not available (as in scratch), inspect from the build stage or use docker export to look at the filesystem.

Step 2: install the bundle

Debian and Ubuntu (including -slim):

RUN apt-get update \
 && apt-get install -y --no-install-recommends ca-certificates \
 && rm -rf /var/lib/apt/lists/*

Alpine:

RUN apk add --no-cache ca-certificates

RHEL, Rocky, Alma, Fedora:

RUN dnf install -y ca-certificates && update-ca-trust

scratch images (typical for Go binaries): copy the bundle from a build stage that has it.

FROM golang:1.22 AS build
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -o /app ./cmd/app

FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /app /app
ENTRYPOINT ["/app"]

Go on Linux looks at standard locations such as /etc/ssl/certs/ca-certificates.crt, so that path works. Pick the Go version your project actually uses. Distroless images vary: some variants include CA certificates and some do not, so check that image's documentation instead of assuming.

Step 3: a corporate proxy or private CA

If the failure only occurs behind a company proxy that re-signs HTTPS traffic, or when calling an internal service with a private CA, you must add that CA certificate. On Debian-style images:

COPY corp-root-ca.crt /usr/local/share/ca-certificates/corp-root-ca.crt
RUN update-ca-certificates

Alpine uses the same directory and command. RHEL-family images use /etc/pki/ca-trust/source/anchors/ with update-ca-trust. The file must be PEM format and, for Debian, end with .crt.

Some runtimes ignore the system store or use their own:

  • Node.js: set NODE_EXTRA_CA_CERTS=/path/to/ca.pem to add to the built-in list.
  • Python requests: uses the certifi bundle by default; set REQUESTS_CA_BUNDLE or SSL_CERT_FILE.
  • Java: uses its own cacerts keystore; see Java PKIX path building failed.

Step 4: stale certificates and clock

An old base image can contain an outdated bundle that lacks newer root certificates, or expired ones. Rebuild from a fresh base image regularly. If errors mention an expired certificate, check the container clock with date -u; containers share the host clock, so a wrong host time breaks validation everywhere.

Verify

Run the failing call from inside the final image, not the build stage:

docker run --rm your-image curl -sSI https://example.com | head -n 3
docker run --rm --entrypoint sh your-image -c 'test -s /etc/ssl/certs/ca-certificates.crt && echo bundle present'

Use the SSL Chain Debugger and TLS Version Checker to separate server-side problems from client-side trust issues. For uptime, keep a monitor on any endpoint your container depends on.

Next steps

FAQ

Why does it work on my laptop but not in Docker?

Your laptop has a full OS trust store. Minimal images may include none, so the same code cannot validate any certificate.

Is installing ca-certificates safe to add to every image?

Yes. It is small and standard, and any image that makes outbound HTTPS calls generally needs it.

Does the certificate expire inside the image?

Root certificates in the bundle can expire or be replaced over time. Rebuilding images regularly picks up the current list.

Do I need ca-certificates for plain HTTP?

No, but nearly everything today uses HTTPS, including package installs and API calls.

Get notified when this fix updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.