gpt4 book ai didi

java SunPKCS11 多个 etokens(智能卡)同时,找不到提供者错误

转载 作者:太空宇宙 更新时间:2023-11-03 13:41:49 25 4
gpt4 key购买 nike

我正在使用 SSL 连接和智能卡提供的 X509 证书。我有 2 个来自 athena 的相同 token 。我在读取证书后初始化 keystore ,但是当我尝试为第二个 token 进行实际连接时,我没有找到我的私钥的提供者。使用第一个 token 连接它不受影响,它可以工作。我尝试通过将 slotIndexList 指定为 1 来添加不同的 SunPCKS11 提供程序,这是由“slots = p11.C_GetSlotList(true)”给出的第二个 token 的编号,但仍然出现相同的错误。当我列出提供程序时:我看到第二个提供程序,但 java 不使用它(我不知道为什么)。

Provider _etpkcs11;
slots = p11.C_GetSlotList(true);

if(slot ==0)
{
String pkcs11config = "name=Athena\nlibrary=C:\WINDOWS\system32\asepkcs.dll";
byte[] pkcs11configBytes =pkcs11config.getBytes();
ByteArrayInputStream configStream = new ByteArrayInputStream(pkcs11configBytes);
etpkcs11 = new SunPKCS11(configStream);
Security.addProvider(etpkcs11);

}

以上作品以下不起作用

if(slot ==1) 
{
String pkcs11config1 = "name=Athenaslot1\nlibrary=C:\WINDOWS\system32\asepkcs.dll";
byte[] pkcs11configBytes1 =pkcs11config1.getBytes();
ByteArrayInputStream configStream1 = new ByteArrayInputStream(pkcs11configBytes1);
etpkcs11 = new SunPKCS11(configStream1);
Security.addProvider(etpkcs11);
}

以下

for(int j=0;j<Security.getProviders().length;j++)
{
System.out.println(Security.getProviders()[j].getName());
}

返回:

SunPKCS11-Athena
SunPKCS11-Athenaslot1
SUN
SunRsaSign
SunEC
SunJSSE
SunJCE
SunJGSS
SunSASL
XMLDSig
SunPCSC

以及使用第二个第二个 token 时的错误:

 No installed provider supports this key: sun.security.pkcs11.P11Key$P11PrivateKey

谢谢

PS:我需要在同一台机器上使用这两个 token

最佳答案

看了these docs之后它是说 SunPKCS11 的实例化可以在配置中占用一个插槽。

也许你可以试试

String pkcs11config1 = "name=Athenaslot1\nslot=1\nlibrary=C:\WINDOWS\system32\asepkcs.dll";

关于java SunPKCS11 多个 etokens(智能卡)同时,找不到提供者错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18438537/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com