1

私の目標は、CAC カードから情報を読み取り、pkcs11それを使用して情報を抽出し、文書に署名することです。ハードウェアに適した dll が見つからなかったので、openSC自分のマシンにインストールしてopensc-pkcs11.dll、次のコードで使用しました。

String configName = "pkcs.cnf"; //my config file that points to opensc-pkcs11.dll
String PIN = "123456";
Provider p = new sun.security.pkcs11.SunPKCS11(configName);
Security.addProvider(p);
KeyStore keyStore = KeyStore.getInstance("PKCS11");
char[] pin = PIN.toCharArray();
keyStore.load(null, pin);

しかし、次の場所でエラーが発生します

 KeyStore keyStore = KeyStore.getInstance("PKCS11");

エラー スタック トレース:

java.security.KeyStoreException: PKCS11 not found
    at java.security.KeyStore.getInstance(Unknown Source)
    Caused by: java.security.NoSuchAlgorithmException: no such algorithm: PKCS11 for provider SunPKCS11-FooAccelerator
    at sun.security.jca.GetInstance.getService(Unknown Source)
    at sun.security.jca.GetInstance.getInstance(Unknown Source)
    at java.security.Security.getImpl(Unknown Source)
    ... 2 more

ヘルプ!

4

1 に答える 1

2

最初に、config.cfg以下に示すように を作成します。

name=name of your CAC card
slot=1
library=C:\Windows\System32\eps2003csp11.dll 
\\This is the dll file for etoken like this when you are installing driver, a separate dll file would be generated for your CAC card.

次に、以下に示すように、プログラムで構成ファイルのパスを指定します。

Provider p = new sun.security.pkcs11.SunPKCS11(configFilepath);
Security.addProvider(p);
于 2016-12-04T07:27:33.313 に答える