MacOS – Java Certificate Issues

certificatejavamacosSecurity

Overview

We are building a JAVA Application that communicates data over secure HTTPS lines.

Problem

When we run our application from Eclipse/Terminal, via the command "java -jar <application>.jar", the application succeeds in all regards. However, when we run our application from "clicking" on the jar file, or when we run it from our bundled OSX Application files, we experience the following error:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

We have added all of the respective certificates to the keystore, and we have tested this extensively. I should also add that we have researched extensively this error, but it mostly resolved around certificate issues. As we can run the application successfully under certain scenarios, we don't believe this is the case.

My current hypothesis is that we need to sign our Java application and/or the OSX Application file generated from our ANT script.

Question

Do any of you have any ideas on what is causing this error? Any ideas on how to fix it?

Best Answer

Literally right after typing this question up, my coworker found the solution.

Apparently, the "JAVA_HOME" variable changes based on the context of where you ran your jar. If you run the application directly, the variable leads to

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

Whereas running it from bash/terminal/eclipse causes it to be located elsewhere

What this means in the context of this problem, is that we were not adding our certificates in all of the places necessary. Should you come across this, please verify that you are adding your certs in the correct locations.