我正在尝试从密钥库文件中获取privateKey,
keyStore.load(KeyStoreinputStream, "keystorepass".toCharArray());
PrivateKey key = (PrivateKey) keyStore.getKey(alias, new char[0]);
new char [0] - >我没有在生成时为私钥提供密码。
低于例外:
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)
答案 0 :(得分:0)
new char[0]
不正确。如果没有密钥密码,请使用null.