如何将 CA 根证书添加到 Jenkins Docker 容器上的 LDAP 密钥库?

How do I add CA root cert to LDAP keystore on Jenkins Docker container?

我想在 Docker 容器中的 Jenkins 上配置 ldaps。

问题:Jenkins 将不信任我的证书(由 Wireshark 跟踪确认),似乎证书未加载到密钥库(或正确的密钥库)

错误信息:

执行的故障排除:

这是我的docker文件:

FROM jenkinsci/blueocean

USER root 

COPY ["entrypoint.sh", "/"]

RUN apk add sudo && chmod 755 /entrypoint.sh

ENTRYPOINT ["/bin/bash","-c","./entrypoint.sh"]

COPY ["ldapRoot.cer", "/tmp"]
RUN \
    cd /tmp \
    && keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias ldapcert -file ldapRoot.cer

这是 docker-compose 的日志输出:

docker-compose up --build
Building jenkins
Step 1/7 : FROM jenkinsci/blueocean
 ---> 9e29fdde63cc
Step 2/7 : USER root
 ---> Using cache
 ---> 597101d109b7
Step 3/7 : COPY ["entrypoint.sh", "/"]
 ---> Using cache
 ---> 32eea6c01a84
Step 4/7 : RUN apk add sudo && chmod 755 /entrypoint.sh
 ---> Using cache
 ---> 28858a5e6ec5
Step 5/7 : ENTRYPOINT ["/bin/bash","-c","./entrypoint.sh"]
 ---> Using cache
 ---> f466e9893c75
Step 6/7 : COPY ["ldapRoot.cer", "/tmp"]
 ---> 64dda06d6ed4
Step 7/7 : RUN     cd /tmp     && keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias ldapcert -file ldapRoot.cer
 ---> Running in 95309101bec9
Certificate was added to keystore
Removing intermediate container 95309101bec9
 ---> cff58441080f
Successfully built cff58441080f
Successfully tagged docker_jenkins:latest
Recreating docker_jenkins_1 ... done

知道我做错了什么吗?

我相信您刚刚创建了一个新的密钥库文件,/tmp/cacerts 而不是更新 /etc/ssl/certs/java/cacerts。如果将 keytool 导入命令更新为指向 /etc/ssl/certs/java/cacerts 会怎样?或者,entrypoint.sh 是否使用 /tmp/cacerts 作为您的信任库?