Interview Prep/Real-World Interview/DNS, TLS and certificates

After switching to a slim base image, the service fails every outbound HTTPS call with "x509: certificate signed by unknown authority".

BeginnerTroubleshootingDNS, TLS and certificates
Answer

Likely causes → The new image has no CA bundle. scratch, some distroless variants and minimal Alpine builds don't ship /etc/ssl/certs/ca-certificates.crt, so the TLS client can't verify any public certificate.

Diagnose →

kubectl exec deploy/api -- ls /etc/ssl/certs/ 2>&1 | head
kubectl exec deploy/api -- wget -qO- https://api.stripe.com 2>&1 | head -3

Fix → Install or copy the bundle:

FROM alpine:3.20 AS certs
RUN apk add --no-cache ca-certificates
FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

For internal CAs, add your corporate root to the bundle too, never set InsecureSkipVerify.

Prevent → A smoke test in CI that makes one real outbound HTTPS call from the built image before it can be promoted.

All Real-World Interview questions Roadmap: Interview readiness

More on DNS, TLS and certificates