-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
beta
-
generic
-
generic
The specififcation says that KeyStore parameter may be null and the specification does not
allow NullPointerException. But the KeyManagerFactory implementation for NewSunX509 algorithm throws NullPointerException if the KeyStore is null.
Note that SunX509 KeyManagerFactory implementation does not throw any exception in this case.
To reptoduce this bug, the following example can be used:
Note the attached keystore should be placed in the current directory in "keystore" file.
----------------Test.java-----------------------
package test;
import java.security.*;
import javax.net.ssl.*;
public class Test {
public static void main(String[] args) {
KeyManagerFactory kmf = null;
char [] password = {' '};
try {
kmf = KeyManagerFactory.getInstance("NewSunX509");
} catch (NoSuchAlgorithmException nsae) {
nsae.printStackTrace();
System.out.println("Failed: Unexpected " + nsae);
return;
}
try {
kmf.init((KeyStore)null, password);
System.out.println("Passed: OKAY.");
} catch (KeyStoreException kse) {
kse.printStackTrace();
System.out.println("Failed: Unexpected " + kse);
} catch (NoSuchAlgorithmException nsae) {
nsae.printStackTrace();
System.out.println("Failed: Unexpected " + nsae);
} catch (UnrecoverableKeyException uke) {
uke.printStackTrace();
System.out.println("Failed: Unexpected " + uke);
}
}
}
allow NullPointerException. But the KeyManagerFactory implementation for NewSunX509 algorithm throws NullPointerException if the KeyStore is null.
Note that SunX509 KeyManagerFactory implementation does not throw any exception in this case.
To reptoduce this bug, the following example can be used:
Note the attached keystore should be placed in the current directory in "keystore" file.
----------------Test.java-----------------------
package test;
import java.security.*;
import javax.net.ssl.*;
public class Test {
public static void main(String[] args) {
KeyManagerFactory kmf = null;
char [] password = {' '};
try {
kmf = KeyManagerFactory.getInstance("NewSunX509");
} catch (NoSuchAlgorithmException nsae) {
nsae.printStackTrace();
System.out.println("Failed: Unexpected " + nsae);
return;
}
try {
kmf.init((KeyStore)null, password);
System.out.println("Passed: OKAY.");
} catch (KeyStoreException kse) {
kse.printStackTrace();
System.out.println("Failed: Unexpected " + kse);
} catch (NoSuchAlgorithmException nsae) {
nsae.printStackTrace();
System.out.println("Failed: Unexpected " + nsae);
} catch (UnrecoverableKeyException uke) {
uke.printStackTrace();
System.out.println("Failed: Unexpected " + uke);
}
}
}