betseyb
betseyb

Reputation: 1332

How to use ssl certificates in Java on a Mac

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.

Upvotes: 2

Views: 9183

Answers (3)

linhadiretalipe
linhadiretalipe

Reputation: 937

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)

Upvotes: -1

rmbrad
rmbrad

Reputation: 1082

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.

Upvotes: 7

betseyb
betseyb

Reputation: 1332

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/ ]

Upvotes: 0

Related Questions