Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6302126

KeyManagerFactory.init method throws unspecified exception for NewSunX509 algorithm

XMLWordPrintable

    • 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);
              }
          }
      }

            xuelei Xuelei Fan
            msokolni Maxim Sokolnikov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: