Witam,
próbuję podpisać dokument z wykorzystaniem karty kryptograficznej KIR. Niestety podczas pobierania listy certyfikatów napotykam na błąd.
String libPath = "C:\\CryptoTech\\CryptoCard\\CCPkiP11.dll";
String pin = "125521";
String pkcs11Config = "name = CryptoTech\nlibrary = " + libPath;
ByteArrayInputStream confStream = new ByteArrayInputStream(pkcs11Config.getBytes());
Provider prov = new sun.security.pkcs11.SunPKCS11(confStream);
Security.addProvider(prov);
KeyStore keyStore = KeyStore.getInstance("PKCS11", prov);
keyStore.load(null, pin.toCharArray());
Enumeration<String> alias = keyStore.aliases();
Logi
xades4j.verification.UnexpectedJCAException: The keystore couldn't be initialized
at xades4j.providers.impl.KeyStoreKeyingDataProvider.ensureInitialized(KeyStoreKeyingDataProvider.java:179)
at xades4j.providers.impl.KeyStoreKeyingDataProvider.getSigningCertificateChain(KeyStoreKeyingDataProvider.java:189)
at xades4j.production.SignerBES.sign(SignerBES.java:151)
at xades4j.production.SignerBES.sign(SignerBES.java:122)
at my.testapp.signer.SignerHelper.signXadesBES(SignerHelper.java:67)
at my.testapp.signer.applet.SignerApplet$2.run(SignerApplet.java:212)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.KeyStoreException: KeyStore instantiation failed
at java.security.KeyStore$Builder$2.getKeyStore(Unknown Source)
at xades4j.providers.impl.KeyStoreKeyingDataProvider.ensureInitialized(KeyStoreKeyingDataProvider.java:175)
... 6 more
Caused by: java.io.IOException: load failed
at sun.security.pkcs11.P11KeyStore.engineLoad(P11KeyStore.java:843)
at java.security.KeyStore.load(Unknown Source)
at java.security.KeyStore$Builder$2$1.run(Unknown Source)
at java.security.KeyStore$Builder$2$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 8 more
Caused by: javax.security.auth.login.LoginException
at sun.security.pkcs11.SunPKCS11.login(SunPKCS11.java:1238)
at sun.security.pkcs11.P11KeyStore.login(P11KeyStore.java:849)
at sun.security.pkcs11.P11KeyStore.engineLoad(P11KeyStore.java:834)
... 12 more
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_PIN_LOCKED
at sun.security.pkcs11.wrapper.PKCS11.C_Login(Native Method)
at sun.security.pkcs11.SunPKCS11.login(SunPKCS11.java:1222)
... 14 more
PIN jest ok, po podaniu tego PINu np. podczas podpisywania Word'a wszystko kończy się sukcesem.
Podając zły pin otrzymałam komunikat
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_PIN_INCORRECT
at sun.security.pkcs11.wrapper.PKCS11.C_Login(Native Method)
at sun.security.pkcs11.SunPKCS11.login(SunPKCS11.java:1222)
... 14 more