Note that there are some explanatory texts on larger screens.

plurals
  1. POjava - path to trustStore - set property doesn't work?
    text
    copied!<p>I've setup a self-signed certificate to test an ssl java connection - however, it is refusing to locate the java trustStore. I've saved copies of it in /Java/jre6/lib/security in addition to the folder where the classes are compiled to (im using netbeans) and also to /java/jre6/bin none of the above appears to work, because when i run the following - trustStore = null.</p> <pre><code>public class ShowTrustStore { public static void main(String[] args) { System.setProperty("javax.net.ssl.keyStore", "keystore.jks"); System.setProperty("javax.net.ssl.trustStrore", "cacerts.jks"); System.setProperty("javax.net.ssl.keyStorePassword", "changeit"); String trustStore = System.getProperty("javax.net.ssl.trustStore"); if (trustStore == null) { System.out.println("javax.net.ssl.trustStore is not defined"); } else { System.out.println("javax.net.ssl.trustStore = " + trustStore); } } } </code></pre> <p>how to set the path correctly?</p> <p>**********UPDATE************ Using the getFile() method and some more debug data:</p> <pre><code>package ssltest; public class Main { public static void main(String[] args) { // System.setProperty("javax.net.ssl.keyStore", "/keystore.jks"); // System.setProperty("javax.net.ssl.trustStrore", "/java.home/cacerts.jks"); // System.setProperty("javax.net.ssl.keyStorePassword", "changeit"); // System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); try { Main.class.getResource("trustStore.jks").getFile(); } catch (Exception e) { e.printStackTrace(); } String trustStore = System.getProperty("javax.net.ssl.trustStore"); if (trustStore == null) { String storeLoc; storeLoc = System.getProperty("java.class.path"); System.out.println("classpath: " + storeLoc); } trustStore = System.getProperty("javax.net.ssl.trustStore"); if (trustStore == null) { System.out.println("javax.net.ssl.trustStore is not defined"); } else { System.out.println("javax.net.ssl.trustStore = " + trustStore); } } } </code></pre> <p>run: java.lang.NullPointerException classpath: C:\Users\Main\Documents\NetBeansProjects\sslTest\build\classes;C:\Users\Main\Documents\NetBeansProjects\sslTest\src at ssltest.Main.main(Main.java:15) javax.net.ssl.trustStore is not defined BUILD SUCCESSFUL (total time: 0 seconds)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload