0

我正在尝试从智能卡获取证书,但是在初始化 Sun PKCS11 提供程序时出现以下错误:

java.security.ProviderException: Initialization failed
    at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:374)
    at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:107)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_TOKEN_NOT_RECOGNIZED
    at sun.security.pkcs11.wrapper.PKCS11.C_GetTokenInfo(Native Method)
    at sun.security.pkcs11.Token.<init>(Token.java:130)
    at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:804)
    at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:365)
    ... 44 more

我的代码:

String providerConfig = "name=PKCS11\r\nlibrary=C:\\WINDOWS\\system32\\UsrPkcs11.dll\r\n";
ByteArrayInputStream providerConfigBAIS = new ByteArrayInputStream(providerConfig.getBytes());
sun.security.pkcs11.SunPKCS11 provider = new SunPKCS11(providerConfigBAIS);

¿ 知道这个错误吗?

提前致谢。

4

0 回答 0