Search code examples
javamavenubuntutruststore

how to change default truststore path


when i run

mvn clean install -Djavax.net.debug=ssl

i get the truststore path as

trustStore is: /home/user/Downloads/jdk8/openjdk-8u40-b25-linux-x64-10_feb_2015/java-se-8u40-ri/jre/lib/security/cacerts

but that's a a wrong path and it end's up giving me this error

Failed to read artifact descriptor for org.springframework.statemachine:spring-statemachine-core:jar:
2.1.3.RELEASE: Could not transfer artifact org.springframework.statemachine:spring-statemachine-core:
pom:2.1.3.RELEASE from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: 
Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

so how can i change the path of the default truststore??

i'am running in ubuntu 18.04 and openjdk 8


Solution

  • Try

    -Djavax.net.ssl.trustStore=/real-path/cacerts -Djavax.net.ssl.trustStorePassword=changeit -Djavax.net.ssl.trustStoreType=jks
    

    As documented here: https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/envvars002.html, you can also export / set the environment variable:

    JAVA_TOOL_OPTIONS="-Djavax.net.ssl.trustStore=/real-path/cacerts -Djavax.net.ssl.trustStorePassword=changeit -Djavax.net.ssl.trustStoreType=jks"