title: java convert pfx to a format that can be imported into default keystore
body: <p>I am programatically loading a certificate into a default keystore with the following code</p>
  
  <pre><code>KeyStore kStore = KeyStore.getInstance(KeyStore.getDefaultType());
  java.io.FileInputStream fis = new FileInputStream(keystorePath);
  kStore.load(fis, new String(keystorePass).toCharArray());
  fis.close();
  </code></pre>
  
  <p>I have a certificate from a third party in pfx format. If I try to load it, it fails with invalid format. </p>
  
  <p>If I update to use the following it works. But I don't want to change the code. </p>
  
  <pre><code>KeyStore keystore = KeyStore.getInstance("PKCS12");  
  </code></pre>
  
  <p>How can I convert the pfx file to a format that will be accepted by the following</p>
  
  <pre><code>KeyStore kStore = KeyStore.getInstance(KeyStore.getDefaultType());    
  </code></pre>