X509: Certificate Signed by Unknown Authority (Running a Go App Inside a Docker Container)
If you ever get the following message:
x509: certificate signed by unknown authority
While running your Go app in a Docker container, there is a chance that you might not have the necessary trusted certificates installed in your Docker container. Assuming that you run your Go apps in lightweight containers, based on Scratch or Alpine, you will have to add the certificates yourselves.
On Alpine, this can be done using the default package installer:
RUN apk --no-cache add ca-certificates
Since Scratch is not based on a particular distribution you would have to download the certificates manually and add them as part of the build process:
ADD ca-certificates.crt /etc/ssl/certs/
Further Reading #
Thank you for reaching this point! If you enjoyed this post or found it helpful, consider supporting my creative journey! Every coffee helps me keep writing and sharing new ideas.
Have something to say? Send me an email or ping me on social media 👇
Want to explore instead? Fly with the time capsule 🛸
You may also find these interesting
What Color is Your Type?
My struggle to choose the right type semantic and keep code consistent at the same time.
Why I Made Peace With Go’s Date Formatting
If we’re all going to google it anyway, we might as well google something that makes sense.
The Two Reasons I Prefer Passing Struct Pointers Around
Choosing consistency over performance.