I was able to use the Sun MSCAPI provider in my application. The problem that I am currently facing is that it always exposes a window asking for a password, even if I provided it in code. This is a problem because I need cryptographic functionality in a web service.
Here is the code that I have now:
String alias = "Alias to my PK"; char[] pass = "MyPassword".toCharArray(); KeyStore ks = KeyStore.getInstance("Windows-MY"); ks.load(null, pass); Provider p = ks.getProvider(); Signature sig = Signature.getInstance("SHA1withRSA",p); PrivateKey key = (PrivateKey) ks.getKey(alias, pass) sig.initSign(key); sig.update("Testing".getBytes()); sig.sign();
This works fine, but I get a popup asking for a password when the last line is run. How to prevent this?
java security cryptography cryptoapi
Sitse
source share