我正在使用SSL連接與智能卡提供的X509證書。 我有2個來自雅典娜的相同的標記。我在讀取證書後初始化密鑰庫,但是當我試圖爲第二個令牌執行實際連接時,我沒有找到爲我的私鑰提供的提供程序。使用第一個令牌進行連接時,它不受影響,它可以工作。 我試着通過將slotIndexList指定爲1來添加不同的SunPCKS11提供程序,第一個是由「slots = p11.C_GetSlotList(true)」給出的第二個標記的編號,但仍然是相同的錯誤。 當我列出提供者時:我看到第二個提供者,但是java不使用它(我不知道爲什麼)。使用第二個是當java SunPKCS11多個etokens(智能卡)同時,提供程序未找到錯誤
SunPKCS11-Athena
SunPKCS11-Athenaslot1
SUN
SunRsaSign
SunEC
SunJSSE
SunJCE
SunJGSS
SunSASL
XMLDSig
SunPCSC
和錯誤:
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());
}
回報第二個問題EN:
No installed provider supports this key: sun.security.pkcs11.P11Key$P11PrivateKey
感謝
PS:我需要同一臺機器
我把插槽,甚至改名爲新的實例,請參閱:SunPKCS11-Athena,SunPKCS11-Athenaslot1。第一個供應商包含行槽= 0,第二個槽= 1。 –