【发布时间】:2020-08-12 02:46:00
【问题描述】:
我有一个这种格式的多阶段 Dockerfile,我正在尝试将自生成的 CA 证书添加到 docker 映像中。
FROM golang:1.13 as builder
RUN cp myCA.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates
# Few more lines here that copy some files I cannot mention
FROM docker.io/alpine@sha256:a15790640a6690aa1730c38cf0a440e2aa44aaca9b0e8931a9f2b0d7cc90fd65
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# Entrypoint command that I cannot mention
我注意到的是,当我基于构建的映像启动 docker 容器并执行到其中时,并 curl 一个其证书由 myCA.crt 签名的 https 端点时,我得到了
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html
但我没想到会得到这个,因为在构建映像时,我确实看到 CA 证书被添加到 CA 证书的受信任列表中
Step 6/20 : RUN update-ca-certificates
---> Running in af768d679d17
Updating certificates in /etc/ssl/certs...
1 added, 0 removed; done.
此外,我进行了故障排除并确认在构建映像的 ca-certificates.crt 中根本找不到指示的 CA 证书。
我还为图像 golang:1.13 启动了一个 docker 容器,并重复了添加指示的 CA 证书的步骤,并且我能够卷曲相同的端点而没有任何错误。
我可能会错过什么?
【问题讨论】:
标签: ssl curl ssl-certificate