[英]Trying to parse PKCS12 generated by WS2016 using Java Keystore: Failed PKCS12 integrity checking
[英]Java keystore failed PKCS12 integrity checking but keytool works
我有一些 PCKS12 证书由两种不同的环境提供服务。 当我们将它上传到 DEV 环境时,java 可以解析它。 但它在生产中失败了。 服务器是负责证书操作的 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());
我可以使用 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 完整性检查错误?
密码不正确或为空。 接受的密码也可以是base64
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.