OpenSC / OpenSC-Java

Using smart cards with Java SE
36 stars 23 forks source link

C_Login for PKCS11 slot 1 failed. (CKR_USER_ANOTHER_ALREADY_LOGGED_IN) #4

Open EduardoDiNizo opened 7 years ago

EduardoDiNizo commented 7 years ago

When I try to perform my tests I get this exception. Does anyone know how to solve this?

------------------ Code ------------------------------------------------------------------------------------- BouncyCastleProvider bcProvider = new BouncyCastleProvider(); Security.addProvider(bcProvider); Connection connection = null; try { connection = new Connection(); } catch (IOException e) { e.printStackTrace(); } KeyStore ks = KeyStore.getInstance("PKCS11", "OpenSC-PKCS11"); PKCS11LoadStoreParameter params = new PKCS11LoadStoreParameter(); params.setSOProtectionPIN("0000".toCharArray()); params.setProtectionPIN("0000".toCharArray());

    PKCS11SessionStore sessionStore = new PKCS11SessionStore();
    sessionStore.open(connection.getProvider(),params);
    System.out.println(sessionStore.getSession().isUserLoggedIn());

    ks.load(params);

------------------ Error ------------------------------------------------------------------------------------- Found provider: SUN Found provider: SunRsaSign Found provider: SunEC Found provider: SunJSSE Found provider: SunJCE Found provider: SunJGSS Found provider: SunSASL Found provider: XMLDSig Found provider: SunPCSC Found provider: BC Found provider: OpenSC-PKCS11 Exception in thread "main" org.opensc.pkcs11.wrap.PKCS11Exception: C_Login for PKCS11 slot 1 failed. (CKR_USER_ANOTHER_ALREADY_LOGGED_IN) at org.opensc.pkcs11.wrap.PKCS11Session.loginNative(Native Method) at org.opensc.pkcs11.wrap.PKCS11Session.loginUser(PKCS11Session.java:146) at org.opensc.pkcs11.PKCS11SessionStore.authenticate(PKCS11SessionStore.java:350) at org.opensc.pkcs11.PKCS11SessionStore.open(PKCS11SessionStore.java:291) at org.opensc.test.pkcs11.tests.SaveCertificate.main(SaveCertificate.java:93)

CKR_USER_ANOTHER_ALREADY_LOGGED_IN: This value can only be returned by C_Login. It indicates that the specified user cannot be logged into the session, because another user is already logged into the session. For example, if an application has an open SO session, and it attempts to log the normal user into it, it will receive this error code.

http://docs.oasis-open.org/pkcs11/pkcs11-base/v2.40/os/pkcs11-base-v2.40-os.html#_Toc416959688