Search code examples
javapkcs#11e-token

etoken unaccessible after reading


I´m trying to read out the certificate of an etoken. I´ve followed the answer from Keystore from digital signature e-token using java. It´s giving me the certificates installed in the token but after that the token isn´t reachable anymore. Did somebody got something similar while accessing a token?

// Create instance of SunPKCS11 provider 
String pkcs11Config = "name=eToken\nlibrary=C:\\path\\to\\your\\pkcs11.dll"; 
java.io.ByteArrayInputStream pkcs11ConfigStream = new java.io.ByteArrayInputStream(pkcs11Config.getBytes()); 
sun.security.pkcs11.SunPKCS11 providerPKCS11 = new sun.security.pkcs11.SunPKCS11(pkcs11ConfigStream); 
java.security.Security.addProvider(providerPKCS11);  // Get provider KeyStore and login with PIN String pin = "11111111"; 
java.security.KeyStore keyStore = java.security.KeyStore.getInstance("PKCS11", providerPKCS11); 
keyStore.load(null, pin.toCharArray());  // Enumerate items (certificates and private keys) in the KeyStore 
java.util.Enumeration<String> aliases = keyStore.aliases(); 
while (aliases.hasMoreElements()) {
    String alias = aliases.nextElement();
    System.out.println(alias); 
}

The problem persists, after plugging out/in the token is reachable again, but after running the code, the token seems to be locked again. OS Win2k8 Server.


Solution

  • Finally got this clear. After disconnecting other USB devices the Token responds as usual.

    The Token should be plugged in to a fully powered port. Best on a separate Host- Bus.