【发布时间】:2020-02-12 18:38:07
【问题描述】:
当我尝试将证书添加到 Keystore 时,我遇到了一个奇怪的错误。
System.out.println(x509Certificate.getPublicKey()); // prints public key, certificate is valid
GlobalStoreManager.getInstance().getSPATruststore().setCertificateEntry(name, x509Certificate); // no error
System.out.println(GlobalStoreManager.getInstance().getSPATruststore().getCertificate(name)); // null
为什么setCertificateEntry 没有抛出任何错误,而getCertificate 仍然返回null?
更新:
我尝试在调用setCertificateEntry() 后立即获取证书别名并且它有效??!所以问题似乎出在getCertificate() 调用而不是setCertificateEntry() 调用?
System.out.println(GlobalStoreManager.getInstance().getSPATruststore().getCertificateAlias(x509Certificate));
谢谢。
【问题讨论】:
-
你的密钥位大小是多少?
-
@Rookie007 2048
-
@Rookie007 也请查看我的更新
-
在你的机器上安装了证书
-
@SapneshNaik 好吧,这可能不是原因,最好检查一下你的 java 的位大小是否超过
256。因为当您尝试设置证书时它甚至没有设置,所以它总是null
标签: java spring-boot x509certificate keystore