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?
- Yes. Open the keystore with the password.Boris the Spider– Boris the Spider2014-05-01 07:25:53 +00:00Commented May 1, 2014 at 7:25
Add a comment |
1 Answer
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