0
我的目標是從CAC卡讀取信息並使用pkcs11
從中提取信息並在我的文檔上簽名。我找不到我的硬件正確的dll,所以我在我的機器上安裝openSC
和下面的代碼中使用opensc-pkcs11.dll
:java.security.KeyStoreException:未找到PKCS11
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
幫助!
我認爲這個問題是您的.dll,支票如果它是你正在引用的正確的dll文件 – mhasan
爲什麼不使用KeyStore keyStore = KeyStore.getInstance(「PKCS11」,p);獲得密鑰庫,可能會幫助你接近你的問題 – mhasan
@ mhasan,那也沒有用。我可以從互聯網上下載該DLL嗎?我正在使用CAC卡 – dexter