Xin chào, tôi đang cố gắng truy cập kho khóa từ thẻ thông minh của mình trong Java. Và tôi đang sử dụng đoạn mã sau ..Mã truy cập Java PKCS11 Không tìm thấy Nhà cung cấp
Tôi đang sử dụng thực hiện Pkcs11 của OpenSc http://www.opensc-project.org/opensc
file windows.cnf =
name=dnie
library=C:\WINDOWS\system32\opensc-pkcs11.dll
Java Mã =
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);
Khi thực hiện theo dòng với =) (= ném cho tôi những ngoại lệ sau đây
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)
Tôi nghĩ vấn đề là "SunPKCS11-DNIe", nhưng tôi không biết phải đặt ở đó. Tôi đã thử với rất nhiều sự kết hợp ...
Bất cứ ai có thể giúp tôi ...
Tôi đã tìm thấy .dll cho trình đọc thẻ thông minh của tôi (asepkcs.dll). Và tôi đã thử lại với cùng một mã (với các gợi ý của @ ColinD) và Hoạt động! Vì vậy, vấn đề là .dll. Bạn phải có dll chính xác cho thiết bị của bạn. – oracleruiz