摘要:当通过OpenSC在PKCS11上使用JCA时,在提取证书时会请求PIN.
我有一个需要使用智能卡签名的应用程序. OpenSC支持智能卡,因此我使用Java内置的pkcs11包装提供程序来使用它.出于功能原因,我需要在没有请求PIN的情况下获取卡中的证书.如果用户最终签名,那么当然需要PIN.
我看到我可以从命令行执行此操作而不提供PIN:
pkcs11-tool --module C:\WINDOWS\system32\opensc-pkcs11.dll -r -a 50-MDS_Signature -y cert -o p.cer
Using slot 1 with a present token (0x1)
到现在为止还挺好.
Oracle的文档明确指出“构建器将根据需要使用先前配置的回调处理程序提示输入密码”(http://docs.oracle.com/javase/6/docs/technotes/guides/security/p11guide.html#Login).但是,我的代码总是请求引脚作为子,因为我调用KeyStore ks0 = ksbuilder0.getKeyStore();即使只提取公共信息(如证书).
遵循代码的摘录:
private static final String PKCS11_LIB = "C:\\WINDOWS\\system32\\opensc-pkcs11.dll";
private static final String NAME = "OpenSCpkcs11";
private static final String SLOT = "1";
private static final String PIN = "11111111";
private static final St