1

我正在使用网络安全服务作为我的 Java 应用程序的 Sun PKCS#11提供程序,但我遇到了一些不受欢迎的行为。

将相同的受信任证书重新插入密钥库将删除最初插入证书时成功设置的信任属性。

下面是一些不完整的代码来演示问题的本质:

Provider p = new SunPKCS11(pkcs11ConFile);

Security.addProvider(p);

KeyStore keystore = KeyStore.getInstance("PKCS11");

keystore.load(null, pwd);

pkcs11Keystore.setCertificateEntry(alias, cert);

//at this point, when I use certutil.exe to list the keystore certificate I can see 
//the certificate listed with attributes "CT,C,C" for SSL,S/MIME,JAR/XPI respectively.

keystore.deleteEntry(alias);

keystore.setCertificateEntry(alias, cert);

//now when I run the same certutil.exe command I see empty trust attributes i.e. ",,".

我仍然能够重新加载相同的密钥库(和证书)并且 SSL 身份验证工作完美,但是,当重新启动应用程序并再次重新加载密钥库时,证书在受信任的别名列表中不可用。

为什么只有在重新启动应用程序时才能正常工作,这对我来说也是一个谜。

我在http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6298106上阅读了一些似乎相关的内容,但它似乎并不适用于 100%,而且我不了解 nss 的内部构造完整的感觉。

有人理解这种行为吗?

谢谢,迈克

4

0 回答 0