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

can't parse some valid X.509 certificates.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • security-libs



      Name: stC104175 Date: 07/26/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1-3-0-C, mixed mode)

      /*
      I am trying to read a certificate that I got from a timestamping service.
      The certificate reads into IE 5 fine.

      The certificate reads into a Java 1.1.7 class fine. The critical line in 1.1.7
      is:
      sun.security.x509.X509Cert cert = new sun.security.x509.X509Cert(bytes);

      In Java 1.2 and 1.3, sun.security.x509.X509Cert is depreciated. So I use the
      new
      classes. The critical line is:
      java.security.cert.X509Certificate cert = (java.security.cert.X509Certificate)
      cf.generateCertificate(bais);
      This line throws an exception:
      java.security.cert.CertificateParsingException: java.io.IOException:
      java.io.IOException: Invalid encoding of AuthorityKeyIdentifierExtension.

      I also tried the keytool -import function on the certificate file and it simply
      says
      Not a X.509 Certificate

      Here's the certificate in question:

      -----BEGIN CERTIFICATE-----
      MIIDmDCCAoCgAwIBAgIBEzANBgkqhkiG9w0BAQUFADB3MQswCQYDVQQGEwJVUzEL
      MAkGA1UECBMCREUxGDAWBgNVBAoTD0RpZ2lTdGFtcCwgSW5jLjEaMBgGA1UEAxMR
      d3d3LmRpZ2lzdGFtcC5jb20xEzARBgNVBAcTCldpbG1pbmd0b24xEDAOBgNVBAsT
      B3Rlc3RUU0EwHhcNOTkwMTA2MDcwODA5WhcNMDEwMTA2MDcwODA5WjBzMQswCQYD
      VQQGEwJVUzELMAkGA1UECBMCREUxGDAWBgNVBAoTD0RpZ2lTdGFtcCwgSW5jLjEa
      MBgGA1UEAxMRd3d3LmRpZ2lzdGFtcC5jb20xEzARBgNVBAcTCldpbG1pbmd0b24x
      DDAKBgNVBAsTA3RzYTCCASEwDQYJKoZIhvcNAQEBBQADggEOADCCAQkCggEAwDlO
      /vE0STfoPzXRKG4d1Y9X+oqbGDz/Fi14aj1z90xsDNC9HsCKjpKhX8/lXnoZ7Nby
      0kBXv7OlQqmQ8hsZgY/4vSm0769ClBXfVuLmAxrDK90PZ92RTwfEY3FWnXRG5K99
      wYzdxviNtJysDGcJWtMOoadCYTORuMDOHy+ft550teUh11B6Bxw7wLN6Zplc0oe3
      tutBrVugTDyzCInxWvMToDsw5vtidhYkNcgjd9xaCnNzgvZ/qta5beXXSFF1s60W
      cdRBgpFDgW2em2U+8xklqk3YQnNNnSwNPyIxBDH8/MlN+sr/BJcnaJfaddzIFRZs
      CfdpddBgdu/3mLhZLwIDAQABozQwMjAOBgNVHSMEBzAFogMCARAwCwYDVR0PBAQD
      AgbAMBMGA1UdJQQMMAoGCCsGAQUFBwMIMA0GCSqGSIb3DQEBBQUAA4IBAQBMCR0R
      +PWeL9ZFMJ4M7/ulbX1QvKbchVjoO/6mJGveZZ6MAlJQBQ92O5rb+q/kZLcchnij
      /PwWGWye7liGpJkkjEVaZv2xgSA0ec9aN+ppMsARDZY/a1VlVkiY2k3ay8eX2ZRY
      Daqjw5lPz7H8vdMGUI5xSP9HqhUsLVUhgss+y465nGTB1vQwhSx4K6ygdrzYnfAW
      QefmOoXJVP346TG9Xi3c4YUjJkb/qCT4upBCqUMVGulRcoq10ScfUVmUR4v0GH97
      gnlxpmUfHWl9h17eVaUwnC1AC6Zpizc7baoP5BQ3MxMsVufCnHotjaw5Vn5hqK5O
      4MyO8yyxITf+QmHM
      -----END CERTIFICATE-----
      */

      import java.io.*;
      import java.security.*;

      class certtest {

          public static void main(String args[])
          {
              try {
                  
               String certfilename = new String("c:\\dgs19t.cer");
               FileInputStream fis = new FileInputStream(certfilename);
               DataInputStream dis = new DataInputStream(fis);
               java.security.cert.CertificateFactory cf =
      java.security.cert.CertificateFactory.getInstance("X.509");
               System.out.println("CertificateFactory created");
               byte[] bytes = new byte[dis.available()];
               dis.readFully(bytes);
               ByteArrayInputStream bais = new ByteArrayInputStream(bytes);

               System.out.println("About to parse certificate");

      // THE NEXT LINE IS THE ONE THAT THROWS THE EXCEPTION!!!
      // TO PROVE THIS, UN-COMMENT THE FOLLOWING LINE, AND COMMENT OUT THE LINE AFTER
      THAT!

      // java.security.cert.X509Certificate cert =
      (java.security.cert.X509Certificate) cf.generateCertificate(bais);

               sun.security.x509.X509Cert cert = new
      sun.security.x509.X509Cert(bytes);




               System.out.println("parseing certificate sucessful");
               System.out.println(cert.toString());
      } catch (java.security.cert.CertificateException e) {
      System.out.println(e);
      } catch (java.io.FileNotFoundException e) {
      System.out.println(e);
      } catch (java.io.IOException e) {
      System.out.println(e);
      }
          }
      }

      // Any help would be appreciated.
      (Review ID: 107583)
      ======================================================================

            mullan Sean Mullan
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: