Hi Chris,
I've found a nice solution to your problem.
A private key can have two different properties when imported into MS CAPI:
1. Enable strong private key protection. You will be prompted every time the private key is used by an application.
2. Mark the key as exportable. This will allow you to back up or transaport your keys at a later time.
I've added these two properties as methods into the existing class
JCAPIKeyStoreProperties to be used when you want to override the default behavior of the
SetKeyEntry method in JCAPI KeyStore. The methods are:
public boolean isCreateExportablePrivateKeysInMsCapi()
public void setCreateExportablePrivateKeysInMsCapi(boolean flag)
public boolean isCreateProtectedPrivateKeysInMsCapi()
public void setCreateProtectedPrivateKeysInMsCapi(boolean flag)
Here is an example of how to reconfigure the key store to import all private keys as non-exportable and no extra protection (no dialog).
KeyStore ks = KeyStore.getInstance("msks", "JCAPI");
ks.load(null, null);
JCAPIKeyStoreProperties ksprop = new JCAPIKeyStoreProperties(ks);
ksprop.setCreateExportablePrivateKeysInMsCapi(false);
ksprop.setCreateProtectedPrivateKeysInMsCapi(false);
The patched JCAPI jar file has been attached to this post.
Let me know what you think about it.
Regards,
Tommy