在我的工作中,我需要使用来自SmartCard的certfifcate签署XML文件。一切正常,但在32位Windows 7 VM上。当我尝试在64位Windows 10上使用相同的代码时出现问题。我收到“未找到PKCS#11”和“没有这样的算法”的错误。我用的是xades4j包。我已经尝试过在网上找到的所有解决方案,即
什么都没有帮助,总是会发生相同的异常。如果有人有任何想法我还能做些什么,我会非常感谢你提示。
最好的祝福。
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
我找到了解决我问题的库。这是https://github.com/esig/dss。我使用JavaSE11(jdk-11.0.2),将pkcs11.dll放在C:/ Windows / System32目录中。在运行应用程序之前,有必要添加VM参数-Djava.security.debug = sunpkcs11,pkcs11