1

I found this question: Import Windows certificates to Java, which had the answer for a Windows machine. I have been unable to find the equivalent to -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT for MacOS.

betseyb
  • 1,302
  • 2
  • 18
  • 37
  • Does it help? https://blog.alwold.com/2011/06/30/how-to-trust-a-certificate-in-java-on-mac-os-x/ – Jorge Campos Apr 23 '18 at 13:57
  • Thanks, but that didn't appear to help. Maven is still unable to find the cert. – betseyb Apr 23 '18 at 14:57
  • I generally do not specify type when setting up trust locally (i.e. on my Mac), usually I only have to specify `javax.net.ssl.trustStore=`. Are you creating a specific type of certificate? – Jacob Apr 23 '18 at 15:00
  • I apparently already have the correct certificate, as I can browse to the repo using a web browser. However, Maven is unable to find it. @JacobBlanton, is the fully qualified path to cacerts, or something else? – betseyb Apr 23 '18 at 15:01
  • Yes that is correct. The file in my case is an organization's root certificate in `.jks` format. – Jacob Apr 23 '18 at 15:06
  • Since you mentioned maven it would be better to add that information on your question. There is nothing mentioning it nor the appropriated tag. An improvement would be add something like "I'm trying to build a maven project using a certificate bla bla bla" and also show the commands you are using. – Jorge Campos Apr 23 '18 at 16:08

3 Answers3

5

On OSX you can set -Djavax.net.ssl.trustStoreType=KeychainStore to use the OSX keychain for trusted certificates; which is part of the Apple JCA Provider.

rmbrad
  • 952
  • 10
  • 13
0

Jacob Blanton provided the solution in his comment, above. By adding -Djavax.net.ssl.trustStore=<path to cacerts> to MAVEN_OPTS in my .bash_profile, both standalone Maven and Maven in Eclipse were able to access the repo as needed [after I installed the cert to cacerts using the instructions Jorge Campos linked to in his comment, found here https://blog.alwold.com/2011/06/30/how-to-trust-a-certificate-in-java-on-mac-os-x/ ]

betseyb
  • 1,302
  • 2
  • 18
  • 37
-1
I am using version 10.14.1 (Mojave).
  1. The path java in my case was: "/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"
  2. In my ~/.bash_profile I put this line:
    export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"
  3. after that I typed source ˜/.bash_profile

  4. type echo echo $JAVA_HOME

  5. Check the configuration typing $JAVA_HOME/bin/java -version
    • You should see something like that:
      java version "1.8.0_211"
      Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
linhadiretalipe
  • 907
  • 7
  • 8