ssl - How to add HTTPS certifications for Java application inside docker? -


i have java application make post request http api protected certificates. when ran locally first time got following exception:

i/o error on post request "https://... sun.security.validator.validatorexception: pkix path building failed: sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target; nested exception javax.net.ssl.sslhandshakeexception: sun.security.validator.validatorexception: pkix path building failed:  sun.security.provider.certpath.suncertpathbuilderexception: unable find valid certification path requested target 

to fix exported certificate firefox , did following:

sudo keytool -import -alias example -keystore  /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts -file /path/to/certificate.der 

reboot , worked.

now want application run on docker. so, have done before, use docker-maven-plugin spotify openjdk base image. first error appears again, try fix same way.

plugin usage:

<plugin> <groupid>com.spotify</groupid> <artifactid>docker-maven-plugin</artifactid> <version>0.4.13</version> <configuration>     <useconfigfile>true</useconfigfile>     <imagename>${project.artifactid}:${project.version}</imagename>     <baseimage>openjdk:latest</baseimage>     <imagetags>         <imagetag>latest</imagetag>         <imagetag>${project.version}</imagetag>     </imagetags>     <resources>         <resource>             <targetpath>/path/${project.artifactid}</targetpath>             <directory>${project.build.directory}</directory>             <include>${project.build.finalname}-jar-with-dependencies.jar</include>         </resource>         <resource>             <targetpath>/path/${project.artifactid}</targetpath>             <directory>${project.basedir}</directory>             <include>certificate.der</include>         </resource>     </resources>     <runs>         <run>$java_home/bin/keytool -import -noprompt -trustcacerts -alias example -file /path/certificate.der -keystore $java_home/jre/lib/security/cacerts -storepass changeit</run>         <run>chmod 555 /path</run>         <run>chmod 444 /path/${project.build.finalname}-jar-with-dependencies.jar</run>     </runs>     <entrypoint>         ["java", "-jar", "/path/${project.build.finalname}-jar-with-dependencies.jar"]     </entrypoint> </configuration> 

the dockerfile generated is:

from openjdk:latest add /path/application.jar /path/ add /path/certificate.der /path/ run $java_home/bin/keytool -import -noprompt -trustcacerts -alias example -file /path/certificate.der -keystore $java_home/jre/lib/security/cacerts -storepass changeit run chmod 555 /path run chmod 444 /path/application.jar entrypoint ["java", "-jar", "/path/application.jar"] 

the problem not fixed. run docker , when post request done have same error if don't have certificate in keystore, 1 mentioned @ beginning. also, if check keystore has certificate.

what missing?

any appreciated :)


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -