File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes keystore problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "keystore problem" Watch "keystore problem" New topic

keystore problem

Paddy Totti

Joined: Dec 12, 2001
Posts: 9
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"
UnrecoverableKeyException:Cannot recover key
at Source)
at Source)
at Source)
at Signature1.main(
Of course, I have create all need and the password is right.
Anyone know why the keystore can't be used ???


Joined: Dec 10, 2001
Posts: 2
Paddy, I also have the similar problem !
I'm trying to authenticate a user using a keystore, this is what I
/* 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!!!~~
I agree. Here's the link:
subject: keystore problem
It's not a secret anymore!