在 64 位上找不到 PKCS#11 库 Windows

PKCS#11 library not found on 64bit Windows

在我的工作中,我需要使用来自 SmartCard 的 certfifcate 签署 XML 文件。一切正常,但在 32 位 Windows 7 VM 上。 当我尝试在 64 位 Windows 10 上使用相同的代码时出现问题。我收到 "PKCS#11 not found" 和 "no such algorithm" 的错误。 我使用 xades4j 包。我已经尝试了可能在网络上找到的所有解决方案,即

  1. 在 32 位和 64 位版本中使用了不同的 .dll 库(pkcs11.dll、opensc-spy.dll、CPPkiP.dll、esp2003csp11.dll)。
  2. 将 .dll 放在 System32 和 SysWOW64 目录中。
  3. 更新了我的 reader (IDBridge CT30) 的驱动程序。
  4. 将 jre 更改为 32 位。
  5. 使用了 PKCS11 参考指南中的解决方案(没有 xades4j)- 它也只适用于 32 位。

没有任何帮助,总是出现相同的异常。如果有人有任何想法我还能做什么,我将非常感谢您的提示。

此致。

Caused by: java.security.KeyStoreException: PKCS11 not found
at java.security.KeyStore.getInstance(Unknown Source)
at java.security.KeyStore$Builder.run(Unknown Source)
at java.security.KeyStore$Builder.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

我找到了解决我问题的库。是https://github.com/esig/dss。我用的JavaSE11(jdk-11.0.2),pkcs11.dll放在C:/Windows/System32目录下。 在 运行 应用程序之前,有必要添加 VM 参数 -Djava.security.debug=sunpkcs11,pkcs11