I am dealing with a mystery in a client in Webservice
authentication with a Serasa A3 card, it always gives the following error when I try to give load in Keystore
:
sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
java.io.IOException: load failed at sun.security.pkcs11.P11KeyStore.engineLoad (P11KeyStore.java:766) at java.security.KeyStore.load (Unknown Source) at br.com.innersolutions.nfe.innernfewscli.InnerNFeWSCli4.nfeStatusServi co (InnerNFeWSCli4.java:750) at screens.TelaNfe $ 8.run (TelaNfe.java:544) Caused by: javax.security.auth.login.LoginException at sun.security.pkcs11.SunPKCS11.login (SunPKCS11.java:1238) at sun.security.pkcs11.P11KeyStore.login (P11KeyStore.java:864) at sun.security.pkcs11.P11KeyStore.engineLoad (P11KeyStore.java:753) ... 3 more Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR at sun.security.pkcs11.wrapper.PKCS11.C_Login (Native Method) at sun.security.pkcs11.SunPKCS11.login (SunPKCS11.java:1222) ... 5 more
When I try to use the Serasa certificate tester application, it closes without giving any error, already in my Java code it gives this error. This program already runs on another client, with the same Serasa A3 certificate, authenticates normally.
The mystery comes from the fact that when we activate Serasa's support, they "identify" that the card is corrupted, and start the exchange process, but this exchange has already been made 4 times! 4 cards with the same problem ???
We have already tried to use the card using another reader, we have tried to use the card on another computer, and the error is always the same.
A little code:
Provider p = new
sun.security.pkcs11.SunPKCS11("C:/Inner/NFe/Certificados/SmartCard.cfg");
Security.addProvider(p);
try {
KeyStore ks = KeyStore.getInstance("PKCS11");
ks.load(null, senhaDoCertificado.toCharArray()); <-------------ERRO AQUI
} catch (IOException e) {
e.printStackTrace();
throw new Exception("Senha do Certificado Digital esta incorreta ou Certificado inválido.");
} catch (KeyStoreException e) {
JOptionPane.showMessageDialog(null, "Verifique se o certficado A3 está corretamente conectado á porta USB do computador");
}
The SmartCard.cfg
name=SmartCard
library=C:/Windows/System32/aetpkss1.dll'
Informações adicionais
Keystore após getInstance do PKCS11:
'SunPKCS11-SmartCard using library C:/Windows/System32/aetpkss1.dll
Information from the Serasa Wizard :
Serasa Experian CD Assistant | Version 3.6.1.3 Windows 7 64-bit Service Pack 1 IE 11.0.9600.19129 SafeSign 64-bit 3.0.87 Jair Standard Card template plugged into the user machine - GD BURTI SCE 3.1 32k Smart card service status automatically started - Executing ActiveX Configuration Status - Executed
Does anyone have any idea what might be happening?