PKCS11 Api试图实例化时抛出此异常,指定的驱动程序安装在Windows32上。
代码:
public static String configFile = "C:\\path_to\\config.cfg";
public static void main(String[] args){
Provider p = new sun.security.pkcs11.SunPKCS11(configFile);
Security.addProvider(p);
}
配置文件:
name = PKTest
library = C:\Windows\System32\aetpkss1.dll
例外:
Exception in thread "main" java.security.ProviderException: Initialization failed
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:376)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:103)
at br.com.keyworks.digitalsigner.test.SignerTest.main(SignerTest.java:19)
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:135)
at sun.security.pkcs11.SunPKCS11.initToken(SunPKCS11.java:858)
at sun.security.pkcs11.SunPKCS11.<init>(SunPKCS11.java:367)
... 2 more