0

I'm written a program in Java that logs me into a website and gathers some information. This website has a self-signed cert and it’s obviously not trusted. When I run my program I started getting this error:

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

So I downloaded the cert and imported it into the default truststore that java uses, then it ran fine in Eclipse. But when I run the program from Windows CMD I get the same error again, I already trusted it in the windows cert store (certmgr.msc). I am not sure where else to trust it to get this program to work from windows command line?

  • 1
    It's possible you're using a different JRE when you run it from the command line vs from Eclipse, with its own keystore location. As far as I know Java does not look in wherever Windows stores certificates, so trusting the certificate in Windows won't help. See [Which is the default location for keystore/truststore of Java applications?](http://stackoverflow.com/questions/4097432/which-is-the-default-location-for-keystore-truststore-of-java-applications) – Jesper Apr 07 '15 at 19:41
  • Thanks! that link helped me research in the right direction, java -D worked for me. But I am not sure what it does exactly, documentation says it sets the system properties but I didnt put a a name or a value after -D and my program worked. not sure whats going on exactly? – Shockmed Apr 13 '15 at 14:26

1 Answers1

0

You need to import the certificate to the JDk keystore (InstallDir/JDK/jre/lib/security) as well as the JRE keystore (InstallDir/jre/lib/security). In my case, Eclipse was using the JDK keystore and the command prompt was using the JRE keystore.