Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

keystore problem  RSS feed

Paddy Totti
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ???

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!~~
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!