找不到Java访问令牌PKCS11提供程序 [英] Java Access Token PKCS11 Not found Provider

查看:125
本文介绍了找不到Java访问令牌PKCS11提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试从Java中的智能卡访问密钥库。我正在使用以下代码。

Hello I'm trying to access the keystore from my smartcard in Java. And I'm using the following code..

我正在使用OpenSc的Pkcs11实现 http://www.opensc-project.org/opensc

I'm using the Pkcs11 implementation of OpenSc http://www.opensc-project.org/opensc

文件windows.cnf =

name=dnie
library=C:\WINDOWS\system32\opensc-pkcs11.dll

Java代码 =

String configName = "windows.cnf"
 String PIN = "####";
 Provider p = new sun.security.pkcs11.SunPKCS11(configName);
 Security.addProvider(p);
 KeyStore keyStore = KeyStore.getInstance("PKCS11", "SunPKCS11-dnie");  =)(= 
 char[] pin = PIN.toCharArray();
 keyStore.load(null, pin);

当执行与 =)(= 一起执行时,抛出以下异常

When the execution goes by the line with =)(= throws me the following exception

java.security.KeyStoreException: PKCS11 not found

    at java.security.KeyStore.getInstance(KeyStore.java:635)
    at ObtenerDatos.LeerDatos(ObtenerDatos.java:52)
    at ObtenerDatos.obtenerNombre(ObtenerDatos.java:19)
    at main.main(main.java:27)
Caused by: java.security.NoSuchAlgorithmException: no such algorithm: PKCS11 for provider SunPKCS11-dnie
        at sun.security.jca.GetInstance.getService(GetInstance.java:70)
        at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
        at java.security.Security.getImpl(Security.java:662)
        at java.security.KeyStore.getInstance(KeyStore.java:632)

我认为问题是 SunPKCS11-dnie,但我没有知道要放在那里。我尝试了很多组合...

I think the problem is "SunPKCS11-dnie", but I don't know to put there. I had tried with a lot of combinations...

任何人都可以帮助我...

Anyone can help me...

推荐答案

我不确定问题出在名字上。看起来很正确。 ColinD的建议以通过 Provider 实例应该排除它是一个问题。

I am not sure the problem is the name. It looks correct. ColinD's suggestion to pass the Provider instance should rule it out as a problem.

我想问题在于PKCS11支持。例如,您的阅读器中没有卡,或者本机代码无法访问阅读器。您是否尝试过将此驱动程序与Firefox或Thunderbird的安全模块等知名的软件结合使用?

I am guessing that the problem is with the PKCS11 support. Like, you don't have a card in your reader, or the native code cannot access the reader. Have you tried using this driver in conjunction with some "known good" software, like Firefox or Thunderbird's security modules?

这篇关于找不到Java访问令牌PKCS11提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆