Subject: Error #3: Key password is wrong
Author: authen
In response to: Error #2: KeyStore password is wrong
Posted on: 02/22/2008 07:51:09 PM
String algorithm = KeyManagerFactory.getDefaultAlgorithm(); // "SunX509"
KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
char[] key_password = "KEY_PASSWORD".toCharArray();
try{
kmf.init(ks, key_password);
}catch(Exception e){
e.printStackTrace();
}
If you guessed the key password wrong, you would most likely see something like this:
java.security.UnrecoverableKeyException: Cannot recover key
at sun.security.provider.KeyProtector.recover(Unknown Source)
at sun.security.provider.JavaKeyStore.engineGetKey(Unknown Source)
at java.security.KeyStore.getKey(Unknown Source)
at com.sun.net.ssl.internal.ssl.SunX509KeyManagerImpl.<init>(Unknown Source)
at com.sun.net.ssl.internal.ssl.KeyManagerFactoryImpl$SunX509.engineInit(Unknown Source)
at javax.net.ssl.KeyManagerFactory.init(Unknown Source)
>
> On 02/22/2008 07:49:20 PM
authen wrote:
char[] keystore_password = "KEYSTORE_PASSWORD".toCharArray();
try{
ks.load(new FileInputStream("path_to_your_keystore"), keystore_password);
}catch(Exception e){
e.printStackTrace();
}
If you guessed the keystore password wrong, you would most likely see something like this:
java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
at java.security.KeyStore.load(Unknown Source)
References: