3

I'm allowing the user to specify its own KeyStore in my application. I'd like to validate that KeyStore password, given by the user, is valid.
Is there a way doing that?

1
  • Yes. Open the keystore with the password. Commented May 1, 2014 at 7:25

1 Answer 1

5

try loading it

FileInputStream is = new FileInputStream(file); KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); /* getting the key*/ keystore.load(is, password.toCharArray()); 

Throws: IOException - if there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.