Subject: Error #2: KeyStore password is wrong
Author: authen
In response to: Error #1: KeyStore type is wrong
Posted on: 02/22/2008 07:49:20 PM
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)
>
> On 02/22/2008 07:46:20 PM
authen wrote:
String keystore_type = KeyStore.getDefaultType(); // "JKS"
try{
KeyStore ks = KeyStore.getInstance(keytore_type);
}catch(Exception e){
e.printStackTrace();
}
By default, the KeyStore type is defined and retrieved from the value of 'keystore.typ' in file
$JAVA_HOME/lib/security/java.security
The value is usually 'JKS' for Sun JRE. You can change it for different type of keystore, e.g. PKCS11, in the file or in your code by property setting :
System.setProperty("javax.net.ssl.keyStoreType", "PKCS11");
If KeyStore type you specified was not supported, you would most likely see something like this:
java.security.KeyStoreException: PKCS11 not found
at java.security.KeyStore.getInstance(Unknown Source)
at com.rli.slapd.server.bio.LDAPListenerSSL.getKeyManagers(LDAPListenerSSL.java:278)
at com.rli.slapd.server.bio.LDAPListenerSSL.getServerSocketFactory(LDAPListenerSSL.java:191)
at com.rli.slapd.server.bio.LDAPListenerSSL.run(LDAPListenerSSL.java:52)
References: