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

CertificateFactory.getCertificates() throws IOException in JDK1.4beta-b55

XMLWordPrintable

    • beta
    • sparc
    • solaris_7

      In JDK 1.4 beta b55 JCK test api/java_security/cert/CertificateFactory/index.html#generate fails. It seems the fix of 4395895 (Cannot import certain X.509 certficates with the Sun JCA implementation) is causing this test to fail.

      Below is minimized test that shows the difference between builds b49 and b55
      =========================
      import java.io.*;
      import java.util.*;
      import java.security.*;
      import java.security.cert.*;

      public class CertificateTest {

          public static void main(String[] argv) {
              Collection c;
              CertificateFactory cf = null;
              /* create an empty SignedData content type in ASN.1
                  SEQUENCE { OBJECT IDENTIFIER (1.2.840.113549.1.7.2)
                              [0] { SEQUENCE { INTEGER
                                               SET
                                               SEQUENCE
                                               {OBJECT IDENTIFIER (1.2.840.113549.1.7.1)}
                                               SET
                                  } }
                           }
                  1.2.840.113549.1.7.2 encoded as : 40*1+2, 86 48, 86 F7 0D, 01, 07, 02
               */
              /*
               create an empty SignedData content type in ASN.1 as defined in PKCS#7
              */
              byte[] b={ 0x30, 0x23,
                             /* contentInfo ::= signedData */
                             0x06, 0x09, 0x2A, (byte)0x86, 0x48,
                                         (byte)0x86, (byte)0xF7, 0x0D,
                                         0x01, 0x07, 0x02,
                             0x00, 0x16,
                                   0x30, 0x14, /* SignedData */
                                         0x02, 0x01, 0x01, /* version */
                                         0x31, 0x00, /* digestAlgorithms */
                                         0x30, 0x0B, /* contentInfo ::= data */
                                             0x06, 0x09, 0x2A, (byte)0x86, 0x48,
                                                         (byte)0x86, (byte)0xF7, 0x0D,
                                                         0x01, 0x07, 0x01,
                                        /* certificates are absent */
                                         0x31, 0x00 /* signerInfos */
                     };
              try {
                  cf = CertificateFactory.getInstance("X509");
              } catch(CertificateException ce) {
                  System.out.println("Unexpected exception "+ce);
              }
          
              try {
                  c = cf.generateCertificates( new ByteArrayInputStream(b));
              } catch(CertificateException ce) {
                  System.out.println("Unexpected exception "+ce);
                  ce.printStackTrace();
              }
              System.exit(0);
              
          }
      }

      =========================
      Output from the test :
      (as58863@novo35(pts/13): ~/tmp .387)
      :\>/opt/build13/jdk1.4/b49/solsparc/bin/java CertificateTest
      (as58863@novo35(pts/13): ~/tmp .388)
      :\>/opt/build13/jdk1.4/b55/solsparc/bin/java CertificateTest
      Unexpected exception java.security.cert.CertificateException: Unable to parse DER value of certificate, java.io.IOException: DerInputStream.getLength(): lengthTag=127, too big.
      java.security.cert.CertificateException: Unable to parse DER value of certificate, java.io.IOException: DerInputStream.getLength(): lengthTag=127, too big.
              at sun.security.x509.X509CertImpl.<init>(X509CertImpl.java:192)
              at sun.security.provider.X509Factory.parseX509orPKCS7Cert(X509Factory.java:352)
              at sun.security.provider.X509Factory.engineGenerateCertificates(X509Factory.java:254)
              at java.security.cert.CertificateFactory.generateCertificates(CertificateFactory.java:417)
              at CertificateTest.main(CertificateTest.java:48)
      (as58863@novo35(pts/13): ~/tmp .389)
      :\>

            smalkanisunw Seema Malkani (Inactive)
            anssunw Ans Ans (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: