title: Load Keystore with null InputStream and password?
body: <p>I came across (inherited) the following code:</p>
  
  <pre><code>String ksType = KeyStore.getDefaultType();
  KeyStore ks   = KeyStore.getInstance(ksType);
  ks.load(null, null);
  SSLSocketFactory sockFactory = new SSLSocketFactory(ks);
  </code></pre>
  
  <p>I am confused by the call to the <code>KeyStore</code> <code>load</code> method.  What keystore is this code using?  I looked at the KeyStore documentation and as far as I can tell this is legitimate.</p>
  
  <p>However, the code does not work.  The app takes a URL for the server to connect to.  The app throws <code>javax.net.ssl.SSLPeerUnverifiedException: No peer certificate</code> errors - even if the site has a valid SSL certificate.</p>
  
  <p>Debugging, I added the following line:</p>
  
  <pre><code>Log.v(TAG,"ks has " + String.valueOf(ks.size()) + " entries.");
  </code></pre>
  
  <p>to get the number of items in the keystore.  It returns zero.</p>
  
  <p>I feel like I am grossly misunderstanding something about KeyStores.</p>
  
  <p>Should this code work? What is it supposed to do?</p>
  
  <p><strong>EDIT</strong>
  Based on how the code is being used (to authenticate websites) I believe it is being used as a truststore, not a keystore.  The <code>SSLSocketFactory</code> that is being used from <code>org.apache.http.conn.ssl</code>.  Looking at the resources for the app, there does not appear to be a keystore file included in the app.  Puzzling to me.</p>