SunPkcs11:CKR_TOKEN_NOT_RECOGNIZED

时间:2013-11-12 14:10:41

标签: java sign

我正在尝试从智能卡获取证书但在初始化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);

¿对此错误有任何想法吗?

提前致谢。

0 个答案:

没有答案