BadPaddingException loading p12 keystore

后端 未结 1 1617
故里飘歌
故里飘歌 2021-01-20 23:54

When executing the following code:

    KeyStore ks = KeyStore.getInstance(storeType);
    ks.load(new FileInputStream(keyStore), storePassword.toCharArray());

          


        
1条回答
  •  旧巷少年郎
    2021-01-21 00:39

    JKS supports using two passwords, one for the store and one for the key inside. PKCS12 does not. When using the keytool, you'll get a warning about this.

    When migrating from to the new keystore, the code will likely continue using the old key password, which in this case is not the same.

    Java 9 gives a much better exception message around this indicating it might arise from a bad key during decryption.

    In this case, make sure to pass in a key password that matches the store password.

    0 讨论(0)
提交回复
热议问题