How to install self signed certificate for Java in Docker/Kubernetes?

5/2/2019

I am running a Spring Boot application in Docker with Kubernetes.

While downloading an image I am getting the below error:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

How can I solve this problem?

-- Hearaman
docker
kubernetes
spring-boot

2 Answers

5/2/2019

Try adding the certificates to the docker image and installing them via keytool

-- Lesiak
Source: StackOverflow

5/2/2019

After adding certificate to the docker now i am able to access the remote site.

Assure I need to download files or access abc.com over https

Add below lines to your Docker file

 USER root
 RUN cd $JAVA_HOME/lib/security && echo -n | openssl s_client -connect abc.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > abc.com.crt &&  keytool -keystore cacerts -keypass changeit -storepass changeit -noprompt -import -v -trustcacerts -alias abc.com -file abc.com.crt
-- Hearaman
Source: StackOverflow