I'm using softhsm.cfg to config connection from a client to the server. Detail that,
name = SoftHSM
library = F:\SoftHSM2\lib\softhsm2-x64.dll
slot = 767671965
attributes(generate, *, *) = {
CKA_TOKEN = true
}
attributes(generate, CKO_CERTIFICATE, *) = {
CKA_PRIVATE = false
}
attributes(generate, CKO_PUBLIC_KEY, *) = {
CKA_PRIVATE = false
}
Then, I connect from client as the following that,
SunPKCS11 provider = new SunPKCS11(Constant.CONFIG_NAME);
if (Security.getProvider(Constant.PROVIDER_NAME) != null) {
Security.removeProvider(Constant.PROVIDER_NAME);
}
Security.addProvider(provider);
The parameter "Constant.CONFIG_NAME" means "softhsm.cfg". And here, I use SunPKCS11 provider. So, how can I create configuration and set attributes in softhsm.cfg by java code 1.8? Thank you so much.