javaxmlsmartcardpkcs#11xades4j

PKCS#11 library not found on 64bit Windows


In my job I have a requirement to sign XML file with certfifcate from SmartCard. Everything works fine but on 32bit Windows 7 VM. The problems occur when I try to use the same code on 64bit Windows 10. I get error that "PKCS#11 not found" and "no such algorithm". I use xades4j package. I've tried probably all solutions found in the web i.e.

  1. Used different .dll libraries (pkcs11.dll, opensc-spy.dll, CPPkiP.dll, esp2003csp11.dll) in both 32 and 64 bits versions.
  2. Placed .dll in both System32 and SysWOW64 directories.
  3. Updated drivers for my reader (IDBridge CT30).
  4. Changed jre to 32bit.
  5. Used solutions from PKCS11 Reference Guide (without xades4j) - it also worked only on 32 bit.

Nothing helps and always the same exceptions occur. If someone have any ideas what else I could do, I will be really thankful for tips.

Best regards.

Caused by: java.security.KeyStoreException: PKCS11 not found
at java.security.KeyStore.getInstance(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)
... 7 more
Caused by: java.security.NoSuchAlgorithmException: no such algorithm: PKCS11 for provider SunPKCS11-SmartCard
at sun.security.jca.GetInstance.getService(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.security.Security.getImpl(Unknown Source)
... 11 more

Solution

  • I found library which solved my problem. It's https://github.com/esig/dss. I used JavaSE11(jdk-11.0.2), pkcs11.dll placed in C:/Windows/System32 directory. Before run application it is necessary to add VM argument -Djava.security.debug=sunpkcs11,pkcs11