Проблема с подписью с квалифицированным сертификатом - смарт-карта PKCS11 - PullRequest
0 голосов
/ 07 декабря 2018

У меня проблема с кодом ниже.Когда я пытаюсь подписать XML-файл, он падает.Полевой PIN-код - это пин-код смарт-карты, и он на 100% правильный.Я не знаю, где проблема.Кто-нибудь может мне помочь?

    PKCS11KeyStoreKeyingDataProvider ptccKeyingDataProv = new PKCS11KeyStoreKeyingDataProvider(
            "C:\\Windows\\System32\\cryptoCertum3PKCS.dll", "CertumQCA2017",
            new FirstCertificateSelector(), new DirectPasswordProvider(PIN), null, false);
    XadesSigner signer = (XadesSigner) new XadesBesSigningProfile(ptccKeyingDataProv)
            .newSigner();
    new Enveloped(signer).sign(elemToSign);

У меня ошибка CKR_FUNCTION_FAILED в строке new Enveloped (signer) .sign (elemToSign);

Полная трассировка стека:

    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:158)
    at xades4j.production.SignerBES.sign(SignerBES.java:129)
    at xades4j.production.Enveloped.sign(Enveloped.java:68)
    at pl.softmedica.ezla.SerwisZLA.zalogujPodpisem(SerwisZLA.java:96)
Caused by: java.security.KeyStoreException: KeyStore instantiation failed
    at java.security.KeyStore$Builder$2.getKeyStore(KeyStore.java:1967)
    at xades4j.providers.impl.KeyStoreKeyingDataProvider.ensureInitialized(KeyStoreKeyingDataProvider.java:175)
    ... 91 more
Caused by: java.io.IOException: load failed
    at sun.security.pkcs11.P11KeyStore.engineLoad(P11KeyStore.java:858)
    at java.security.KeyStore.load(KeyStore.java:1479)
    at java.security.KeyStore$Builder$2$1.run(KeyStore.java:1937)
    at java.security.KeyStore$Builder$2$1.run(KeyStore.java:1918)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.KeyStore$Builder$2.getKeyStore(KeyStore.java:1964)
    ... 92 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:864)
    at sun.security.pkcs11.P11KeyStore.engineLoad(P11KeyStore.java:849)
    ... 97 more
    Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_FUNCTION_FAILED
    at sun.security.pkcs11.wrapper.PKCS11.C_Login(Native Method)
    at sun.security.pkcs11.SunPKCS11.login(SunPKCS11.java:1222)
    ... 99 more
...