When I do in the cmd line:
pkcs11-tool --login -O
I get seven Objects that are on my smartcard, 3 Public Key Objects, 3 Certificate Objects and one Private Key Object.
But when I try to do the same with a small Java Code, I only find one Certificate:
String pkcs11Config = "name = SmartCard\nlibrary = opensc-pkcs11.dll\nslot=0";
ByteArrayInputStream confStream = new ByteArrayInputStream(pkcs11Config.getBytes());
Provider prov = new sun.security.pkcs11.SunPKCS11(confStream);
Security.addProvider(prov);
String pin = "0000000";
KeyStore cc = KeyStore.getInstance("PKCS11", prov);
cc.load(null, pin.toCharArray());
// Look for certificate
Enumeration aliases = cc.aliases();
for (Enumeration e = aliases; e.hasMoreElements();) {
Object alias = aliases.nextElement();
System.out.println("Alias is : " + alias);
}
Why Do I found no Public key or other Certificate with this code?