title: Java: Loading SSL Keystore via a resource
body: <p>If I have:</p>
  
  <pre><code>System.setProperty("javax.net.ssl.keyStore", '/etc/certificates/fdms/WS1001237590._.1.ks');
  System.setProperty("javax.net.ssl.keyStorePassword", 'DV8u4xRVDq');
  System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
  </code></pre>
  
  <p>I'm able to open a secure connection without a problem.</p>
  
  <p>However, I'd like to have the certificates stored directly in the war, so I use: (The file input stream will eventually become a resource stream, but I'm doing this to get it to work.)</p>
  
  <pre><code>System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
  KeyStore ks = KeyStore.getInstance("JKS");
  ks.load(new FileInputStream("/etc/certificates/fdms/WS1001237590._.1.ks"), "DV8u4xRVDq".toCharArray());
  KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
  kmf.init(ks, "DV8u4xRVDq".toCharArray());
  SSLContext sc = SSLContext.getInstance("TLS");
  sc.init(kmf.getKeyManagers(), null, null);
  </code></pre>
  
  <p>Now, if I open the same connection, I get: <code>javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure</code></p>