Code:
String pkcs11cfg = "pkcs11.cfg";
Provider p = new SunPKCS11(pkcs11cfg);
Security.addProvider(p);
KeyStore ks = KeyStore.getInstance("PKCS11", p);
ks.load(null, pin);
System.out.println(ks.size()); // prints 0
cfg:
name = pkcs11Test
library = /usr/local/lib/libsofthsm.so
slot = 1
The problem is that I have some key pairs, I added them with pkcs11-tool.
The version of softhsm is 1.2.1
Why there aren't any aliases in the KeyStore? How to fix this?
We will release SoftHSM 1.3.0 soon. It has support for certificates and is tested with Java.
SoftHSM.java:
softhsm.cfg: