Java密钥库未通过PKCS12完整性检查但keytool工作

时间:2018-05-16 06:36:07

标签: java certificate

我有一些PCKS12证书,两种环境的服务方式不同。当我们将它上传到DEV环境时,java可以解析它。但它在PRODuction上失败了。服务器是Microsoft DotNet解决方案,负责证书操作。生成的密钥库具有空密码。当我在Windows中打开证书时,我可以成功将其导入操作系统 - 无需密码。

我可以使用keytool列出 DEV 证书,但表示很奇怪:

Keystore type: PKCS12
Keystore provider: SunJSSE

Your keystore contains 1 entry

Alias name: {8c6xx9f-8041-49d2-95f7-3bcffxxxc8bcf}
Creation date: 15.5.2018
Entry type: PrivateKeyEntry

*******************************************
*******************************************

但我可以在java中打开它

KeyStore keyStore = KeyStore.getInstance("pkcs12");
keyStore.load(fis, "".toCharArray());

使用Keystore Explorer浏览它: enter image description here

我可以使用keytool正确列出 PROD 证书:

Keystore type: PKCS12
Keystore provider: SunJSSE

Your keystore contains 1 entry

Alias name: {9exx43e-83f8-405d-8f74-8b1xxxeaac37}
Creation date: 15.5.2018
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: OID.2.5.4.13=YCCere01, CN=CZ7, DC=CZ
Issuer: CN=EET CA 1, O=Česká Republika ? Generální finanční ředitelství, DC=CZ
Serial number: 84cxxxc6
Valid from: Wed May 09 16:11:43 CEST 2018 until: Sun May 09 16:11:43 CEST 2021
Certificate fingerprints:
         MD5:  21:CB:24:AE:4D:F5:EE:4D:C9:6A:A0:DD:AA:2F:6F:A8
         SHA1: 02:0F:6B:C2:B8:E5:18:16:F9:49:28:4F:9E:F6:63:5C:D0:6E:6B:95
         SHA256: B8:37:57:66:1A:33:31:BD:DB:4E:AB:9C:E5:31:C3:18:2B:96:88:A9:1B:21:85:30:97:D9:BB:F7:84:7B:4A:52
         Signature algorithm name: SHA256withRSA
         Version: 3

但java和Keystore Explorer都无法打开它:

Exception in thread "main" java.io.IOException: Integrity check failed: 
java.lang.SecurityException: Failed PKCS12 integrity checking
at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2058)
at java.security.KeyStore.load(KeyStore.java:1445)
at Main.main(Main.java:17)
Caused by: java.lang.SecurityException: Failed PKCS12 integrity checking
at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2054)

知道问题出在哪里?密码真的是空的,因为我能够在没有它的情况下将密钥导入Windows。 Keytool可以列出其内容 - 那么为什么java API无法使用PKCS12完整性检查错误打开它?

0 个答案:

没有答案