• Post Reply Bookmark Topic Watch Topic
  • New Topic

Change password for the KeyStore programmatically  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI My Client asked us to create user interface for change the keystore password.

I created KeyStore like this
=====================================================================
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(null, keyStorePwd.toCharArray());

FileOutputStream out = new FileOutputStream(keystoreName);
keystore.store(out, keyStorePwd.toCharArray());
out.close();
=====================================================================
But i dont see any method in api to change the password for keystore. Please help me how to change Keystore password from old password to new password.

Thanks in advance.
Dhananjayan Karnam
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The keytool utility does that; you can't do it programmatically.
 
Dhananjay karnam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Ulf, Thanks for the reply.

We are developing B2B application and in our side we need to provide certificate for calling the other server. So they asked me to create a tool to import certificates to the keystore.

But here my issue is client side security people wants to handle that through some interface, they dont know how to work with the keytool and in production noone have access to that.

So tell me if i have 2 keystores in the classpath (keystore1 and keystore2) and if user request for a change password , then i will point to keystore2 from keystore1 and create that with the said password and export all certificates from keystore1 and save into keystore2. Next time if again request for change password i will create keystore1 with the new password and export all certificates.

The only thing is i need to track which keystore i need to use at runtime.
Is this logic works ulf.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!