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

Keystore created under Hindi Locale causing ArrayIndexOutOfBoundsException

    Details

    • Subcomponent:
    • Resolved In Build:
      b105
    • CPU:
      x86
    • OS:
      windows_vista
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows Vista, Windows Server 2008 ( early access )

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      User Locale is Hindi

      A DESCRIPTION OF THE PROBLEM :
      The keystore.db which is created under hindi locale is throwing exception while accessing it. Even the standard utility keytool is also failing to access the data.

      Steps:

      1. Change the Windows Vista system "Regional and Language options" current Format to "Hindi ( India )" and Location to "India"

      2. Create the keystore.db using Sun JDK's keytool utility. ( Available with Standard JDK installation )

      keytool.exe -genkey -keystore "c:\temp\keystore.db" -keyalg RSA -sigalg MD5withRSA -alias myAlias -storepass password -dname "cn=myMachine,ou=busines,o=org,l=location,s=state C=country"

      Enter key password for <myAlias>
              (RETURN if same as keystore password):
      Re-enter new password:

      3. Access the keystore.db using Sun JDK's keytool utility.
      keytool.exe -list -keystore "c:\temp\keystore.db"
      resulting in:
      keytool error: java.lang.ArrayIndexOutOfBoundsException: 13


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Java API fails on Hindi Locale:

      1. Change the Windows Vista system "Regional and Language options" current Format to "Hindi ( India )" and Location to "India"

      2. Create the keystore.db using Sun JDK's keytool utility. ( Available with Standard JDK installation )

      keytool.exe -genkey -keystore "c:\temp\keystore.db" -keyalg RSA -sigalg MD5withRSA -alias myAlias -storepass password -dname "cn=myMachine,ou=busines,o=org,l=location,s=state C=country"

      Enter key password for <myAlias>
              (RETURN if same as keystore password):
      Re-enter new password:

      3. Access the keystore.db using Sun JDK's keytool utility.
      keytool.exe -list -keystore "c:\temp\keystore.db"
      keytool error: java.lang.ArrayIndexOutOfBoundsException: 13

      4. Try to access the keystore.db using java code.

      C:\temp>java.exe -cp . TestProgram c:\temp\keystore.db
      Exception occured:java.lang.ArrayIndexOutOfBoundsException: 13
      java.lang.ArrayIndexOutOfBoundsException: 13
             at sun.util.calendar.BaseCalendar.getDayOfYear(Unknown Source)
      at sun.util.calendar.BaseCalendar.getFixedDate(Unknown Source)
      at sun.util.calendar.BaseCalendar.getFixedDate(Unknown Source)
             at sun.util.calendar.AbstractCalendar.getTime(Unknown Source)
      at sun.security.util.DerInputBuffer.getTime(Unknown Source)
             at sun.security.util.DerInputBuffer.getUTCTime(Unknown Source)
      at sun.security.util.DerInputStream.getUTCTime(Unknown Source)
             at sun.security.x509.CertificateValidity.construct(Unknown Source)
      at sun.security.x509.CertificateValidity.<init>(Unknown Source)
             at sun.security.x509.X509CertInfo.parse(Unknown Source)
      at sun.security.x509.X509CertInfo.<init>(Unknown Source)
             at sun.security.x509.X509CertImpl.parse(Unknown Source)
      at sun.security.x509.X509CertImpl.<init>(Unknown Source)
             at sun.security.provider.X509Factory.engineGenerateCertificate(Unknown Source)
      at java.security.cert.CertificateFactory.generateCertificate(Unknown Source)
             at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
      at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
             at java.security.KeyStore.load(Unknown Source)
      at TestProgram.main(TestProgram.java:26)

      If we run the same steps in English or some other locale which has code pages, we are successfully able to access the data in keystore.db.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      expected to print the finger print of myAlias like the following

      Keystore type: jks
      Keystore provider: SUN

      Your keystore contains 1 entry

      myalias, Mar 3, 2008, keyEntry,
      Certificate fingerprint (MD5): 54:C1:12:23:C8:8E:E2:C6:38:3A:2A:1B:4C:53:44:3C
      ACTUAL -
      keytool error: java.lang.ArrayIndexOutOfBoundsException: 13


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception occured:java.lang.ArrayIndexOutOfBoundsException: 13
      java.lang.ArrayIndexOutOfBoundsException: 13
             at sun.util.calendar.BaseCalendar.getDayOfYear(Unknown Source)
      at sun.util.calendar.BaseCalendar.getFixedDate(Unknown Source)
      at sun.util.calendar.BaseCalendar.getFixedDate(Unknown Source)
             at sun.util.calendar.AbstractCalendar.getTime(Unknown Source)
      at sun.security.util.DerInputBuffer.getTime(Unknown Source)
             at sun.security.util.DerInputBuffer.getUTCTime(Unknown Source)
      at sun.security.util.DerInputStream.getUTCTime(Unknown Source)
             at sun.security.x509.CertificateValidity.construct(Unknown Source)
      at sun.security.x509.CertificateValidity.<init>(Unknown Source)
             at sun.security.x509.X509CertInfo.parse(Unknown Source)
      at sun.security.x509.X509CertInfo.<init>(Unknown Source)
             at sun.security.x509.X509CertImpl.parse(Unknown Source)
      at sun.security.x509.X509CertImpl.<init>(Unknown Source)
             at sun.security.provider.X509Factory.engineGenerateCertificate(Unknown Source)
      at java.security.cert.CertificateFactory.generateCertificate(Unknown Source)
             at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
      at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
             at java.security.KeyStore.load(Unknown Source)
      at TestProgram.main(TestProgram.java:26)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      TestProgram.java
      --------------------------
      import java.lang.*;
      import java.text.*;
      import java.util.*;
      import java.security.*;
      import javax.crypto.spec.*;
      import javax.crypto.*;
      class TestProgram{

         
          
          public static void main(String args[])
          {

      //setting the default password as password.
           char[] password = new String("password").toCharArray();
          
           java.io.FileInputStream fis = null;
          
           KeyStore ks = null;
           try{
           ks = KeyStore.getInstance(KeyStore.getDefaultType());
               fis = new java.io.FileInputStream(args[0]);
           try {
          
           //This is the place which throws the exception
               ks.load(fis, password);

      }catch(Exception ee){
           System.out.println("Exception occured:" + ee);
           ee.printStackTrace();
           }//inner catch block
           finally {
               if (fis != null) {
                   fis.close();
               }
              }//finally
           }catch(Exception ee){
           System.out.println("Exception occured:" + ee);
           ee.printStackTrace();
          
           }

          
          }//main function
          
       }//end of class


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      create the keystore in english language, then it is accessible in all locales

        Attachments

          Activity

            People

            • Assignee:
              weijun Weijun Wang
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: