0
I’m dealing with a mystery in a client’s authentication Webservice
with a Serasa A3 card, it always gives the following error when I try to load the 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 telas.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 A3 certificate as Serasa, normally authenticates.
The mystery comes that when we call the support of Serasa, they "identify" that the card is corrupt, and start the exchange process, only that this exchange has been done 4 times! 4 cards with the same problem???
We have tried to use the card using another reader, we have tried to use the same on another computer, and the error is always the same.
A little bit of 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 archive 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 Wizard Serasa:
Serasa Experian CD Wizard | 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 model plugged into user machine - GD BURTI SCE 3.1 32k Smart card service status started automatically - Running Activex Configuration Status - Run
Does anyone have any idea what might be going on?