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

CertificateFactory.generate{Certificates,CRLs} impl only parses 1 Cert/CRL

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • security-libs
    • None
    • beta
    • sparc
    • solaris_7

      The implementation of generateCertificates does not handle a sequence of DER encoded certs correctly. It only parses 1 certificate, and ignores any subsequent certs. The offending code is in the parseX509orPKCS7Cert() method of sun/security/provider/X509Factory.java:

          private Collection parseX509orPKCS7Cert(InputStream is)
              throws CertificateException
          {
              try {
                  // treat as X.509 cert
                  is.mark(is.available());
                  X509CertImpl cert = new X509CertImpl(is);
                  return Arrays.asList(new X509Certificate[] { cert });

      This code should continue to look for more certs in the input stream.

      Also, the javadoc for generateCertificates should be a bit more clear about the
      format of the data for a sequence of DER encoded certs. Its the word 'sequence' that is confusing, since the caller could interpret this as meaning a DER encoded ASN.1 Sequence of certs. That is incorrect. What we mean here is something like:

      -----BEGIN CERTIFICATE-----
      blalala
      -----END CERTIFICATE-----
      -----BEGIN CERTIFICATE-----
      blalala
      -----END CERTIFICATE-----
      -----BEGIN CERTIFICATE-----
      blalala
      -----END CERTIFICATE-----

            mullan Sean Mullan
            mullan Sean Mullan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: