ssl - java SunPKCS11 multiple etokens(smartcards) same time , provider not found error -


i using ssl connection x509 certificates provided smartcards. have 2 identical tokens athena . initialise keystores after reading certificates, when trying to actual connection second token getting no provider found private key.connecting using first token it's not affected, works. tried adding different sunpcks11 provider specifing slotindexlist 1 , number second token given "slots = p11.c_getslotlist(true)", still same error. when listing providers: see second provider, java doesn't use (i don't know why).

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

the above works following doesn't work

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

the following

for(int j=0;j<security.getproviders().length;j++)         {             system.out.println(security.getproviders()[j].getname());            } 

returns:

sunpkcs11-athena sunpkcs11-athenaslot1 sun sunrsasign sunec sunjsse sunjce sunjgss sunsasl xmldsig sunpcsc 

and error when using second second token:

 no installed provider supports key: sun.security.pkcs11.p11key$p11privatekey 

thanks

ps: need both tokens on same machine

after having @ these docs saying instantiation of sunpkcs11 can take slot in configuration.

so maybe try

string pkcs11config1 = "name=athenaslot1\nslot=1\nlibrary=c:\windows\system32\asepkcs.dll"; 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -