hi,I am doing the digital signature.Here is my problem: After I have create my keystore, i wrote a program to use it. However, when I run this program with this line in dos/mode: java SignatureTest -s .keystore tsyfhedr Paddy custorder.xml signaturefile It throws a exception: Exception in thread "main" java.security. UnrecoverableKeyException:Cannot recover key at sun.security.provider.KeyProtector.recover(Unknown Source) at sun.security.provider.JavaKeyStore.engineGetKey(Unknown Source) at java.security.KeyStore.getKey(Unknown Source) at Signature1.main(Signature1.java:32) Of course, I have create all need and the password is right. Anyone know why the keystore can't be used ???
child
Greenhorn
Joined: Dec 10, 2001
Posts: 2
posted
0
Paddy, I also have the similar problem ! I'm trying to authenticate a user using a keystore, this is what I try: ... /* Associate a FileReader with the file */ File keyStoreFile = new File("OVS.keystore"); FileInputStream keyStoreFileInputStream = new FileInputStream(keyStoreFile);
KeyStore ks = KeyStore.getInstance("JKS"); /* load the KeyStore from the given inputstream, using the given password */ ks.load(keyStoreFileInputStream, password); ks.getKey(username, password); <<<<<<----- HERE IS PROBLEM ??? // authentication succeeded!!! passwordCorrect = true; if (debug) System.out.println("\t\t[SampleLoginModule] " + "authentication succeeded"); succeeded = true; ...
I am putting all this in a try-catch block so if ks.getKey(...) doesn't generate an exception, it means that authentication succeeded, and if it does generate an exception, i go to the 'authentication did not succeed' part of my program. Still, it seems like the ks.getKey(username, password) generates an exception EVERY TIME that tells me: "Cannot recover key". There _is_ a keystore that i created with the keytool in the working directory. What am I doing wrong here? How should I authenticate users that are defined in a KeyStore using the keytool program? I think we may need to set something on the keystore! But anyone can help plz!!!~~