Importing self-signed cert into Docker's JRE cacert is not recognized by the service

前端 未结 3 741
渐次进展
渐次进展 2020-12-14 02:31
  • A Java Service is running inside the Docker container, which access the external HTTPS url and its self-sign certificate is unavailable to the service/ JRE cacert keys
3条回答
  •  清歌不尽
    2020-12-14 03:09

    For using already configured java based containers like jenkins, sonarqube or nexus (e. g. if you run your own build server) I find it more convenient to mount a suitable cacerts-file into these containers with a parameter for docker run .

    I use the cacerts file from openjdk as base:

    1. extracting cacerts from openjdk image using a temporary container:
    docker pull openjdk:latest
    docker run --rm --entrypoint cat openjdk:latest /etc/ssl/certs/java/cacerts > cacerts
    
    1. adding certificate to the extracted cacerts using a temporary container started from the same folder which also contains ldap.cer:
    docker run --rm -v `pwd`:/tmp/certs openjdk:latest bash -c 'cd /tmp/certs && keytool -keystore cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias buenting-root -file ldap.cer'
    
    1. run your target docker container(s) mounting the extracted cacerts with a run-parameter, e. g. for sonarqube:
    docker run ... -v /path/to/your/prepared/cacerts:/etc/ssl/certs/java/cacerts:ro ... sonarqube:lts
    

    If there is a new version of openjdk you can update the cacerts-file on the host with commands from 1. and 2.

    For updating the target image (e. g. sonarqube) you do not need to create your own image using Dockerfile and docker build.

提交回复
热议问题