Java密钥库无法将X509Certificate添加到密钥库

Java密钥库无法将X509Certificate添加到密钥库,java,spring-boot,x509certificate,keystore,Java,Spring Boot,X509certificate,Keystore,当我尝试向密钥库添加证书时,我遇到了一个奇怪的错误 System.out.println(x509Certificate.getPublicKey()); // prints public key, certificate is valid GlobalStoreManager.getInstance().getSPATruststore().setCertificateEntry(name, x509Certificate); // no error System.out.println(Gl

当我尝试向密钥库添加证书时,我遇到了一个奇怪的错误

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));

谢谢。

在setCertificateEntry()中使用别名。用keytool试试。

你的钥匙位大小是多少?@Rookie0072048@Rookie007请查看我的更新并在ur中安装证书machine@SapneshNaik好吧,也许这不是原因,检查java的位大小是否大于
256
总是更好的。因为当您试图设置证书时,它甚至没有被设置,所以它总是
null