title: How to get PrivateKey from keystore.pkcs12 file
body: <p>I am trying to get privateKey from keystore file,</p>
  
  <pre><code>    keyStore.load(KeyStoreinputStream, "keystorepass".toCharArray());
  
  PrivateKey key = (PrivateKey) keyStore.getKey(alias, new char[0]);
  </code></pre>
  
  <p>new char[0] --> I have not given password for private key at the time of generation.</p>
  
  <p><strong>getting below exception:</strong></p>
  
  <pre><code>java.security.UnrecoverableKeyException: Get Key failed: Given final block not properly padded
      at java.security.KeyStore.getKey(KeyStore.java:792)
  Caused by: javax.crypto.BadPaddingException: Given final block not properly padded
      at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
      at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
      at com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(PKCS12PBECipherCore.java:355)
  </code></pre>