1

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

  • 1
    Does this answer your question? [java - path to trustStore - set property doesn't work?](https://stackoverflow.com/questions/2138574/java-path-to-truststore-set-property-doesnt-work) – Marged Jan 16 '20 at 15:15
  • Why is this the "wrong path"? It seems to me that (extremely old!) Java version is what is getting used to run Maven, so if that is the case, it would be the 'right path'. – Mark Rotteveel Jan 16 '20 at 16:54
  • @Marged no , i looked into it and it seem to manually set the trustrore in a java application wheras i was looking it to set it for maven configuration so i din't have to use a extra option i.e `-Djavax.net.sst.trustStore` –  Jan 17 '20 at 07:18
  • @MarkRotteveel well after downloading the zip file (where the location is pointing) i installed java using `apt-get` and now i want maven to take the file at `/usr` folder and not the `/Downloads` folder –  Jan 17 '20 at 07:20

1 Answers1

4

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"
  • hey , Jose thank you for the answer , it has worked for me but i was looking for more a permanant change , where i din't have to add `-Djavax.net.ssl.trustStore` option for each and every maven application. –  Jan 17 '20 at 07:22
  • In that case you may use JAVA_TOOL_OPTIONS environment variable. I have edited the answer. Please accept the answer if it worked for you! Thanks! – Jose Manuel Gomez Alvarez Jan 18 '20 at 11:41
  • one last doubt , you mean change enviorment variable in `/etc/profile` or `/etc/enviorment` ?? –  Jan 23 '20 at 13:31
  • yes, it depends on the operating system and whether you want this variable to be set for all users or for only one user... For all users and unix systems, the /etc/profile, or as recommended in your distribution. For Linux it is discouraged, instead they invite you to do the change in a new script in /etc/profile.d/.sh – Jose Manuel Gomez Alvarez Jan 24 '20 at 14:14
  • Remind you to kindly upvote / accept if my answer was helpful. Thanks – Jose Manuel Gomez Alvarez Jan 24 '20 at 14:25
  • it's not working , i added a file called 'java-tools.sh` and exported the `JAVA_TOOL_OPTIONS` but i still get the same error. –  Jan 27 '20 at 08:10
  • Maybe you are not using the right syntax to export the variable. Try: EXPORT JAVA_TOOL_OPTIONS=... and make sure that if you use any startup script, to run the application, it does not override this value! I edit the answer to include a reference to the Oracle page where this is documented, so it must work. Now, the set up of the variable is out of the scope of this question, as it depends on your particular operating system and environment. – Jose Manuel Gomez Alvarez Jan 27 '20 at 09:45
  • my bad i was using `JAVA_TOOL_OPTION` missing `s` –  Jan 27 '20 at 10:39