如何从 keystore.pkcs12 文件中获取私钥
How to get PrivateKey from keystore.pkcs12 file
我正在尝试从密钥库文件中获取私钥,
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)
new char[0]
不正确。如果没有密钥密码,使用null.
我正在尝试从密钥库文件中获取私钥,
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)
new char[0]
不正确。如果没有密钥密码,使用null.