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

X509Certificat is not created on some BASE64 encoded certificates

XMLWordPrintable

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



      Name: rlT66838 Date: 03/21/2000


      java version "1.2.2"
      Classic VM (build Linux_JDK_RC3, native threads, sunwjit)

      java version "1.2.1"
      Solaris VM (build Solaris_JDK_1.2.1_04, native threads, sunwjit)


      the following certificate cannot be loaded by
      CertificateFatory.generateCertificate(bytestream)

      -----BEGIN CERTIFICATE-----
      MIICfzCCAegCATYwDQYJKoZIhvcNAQEFBQAwgYoxCzAJBgNVBAYTAktSMQ4wDAYD
      VQQHEwVEYWVndTERMA8GA1UEChQItOuxuMC6x+AxEzARBgNVBAsUCsDOxc2z3bnw
      xbcxHDAaBgNVBAMTE3d3dy5kYWVndWJhbmsuY28ua3IxJTAjBgkqhkiG9w0BCQEW
      Fm1haWx0b0BkYWVndWJhbmsuY28ua3IwHhcNMDAwMzE1MTI0MzI3WhcNMDEwMzE1
      MTI0MzI3WjCBhDEaMBgGA1UEAxQRx8O3r7HXwM4gMi4wIMDaudkxITAfBgkqhkiG
      9w0BCQEWEndha2Fub0Bpbml0ZWNoLmNvbTETMBEGA1UECxQKwM7FzbPdufDFtzER
      MA8GA1UEChQItOuxuMC6x+AxDjAMBgNVBAcTBWRhZWd1MQswCQYDVQQGEwJLUjCB
      nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2xHB5JUZ1tRFfA2urIvl28UP7Ltt
      HeGzrJCVsD52DXlvhf19KoGYNYQO+n6PqavlSBVeqNuOqZhpypSnkybY9SumvfU4
      3uboyIm3JCmwfyNpon8j8e9PNr/1a4RljaAexHIVSW882dngeIIY/Jr2wu3o7vo2
      u35jbEnx+KBhjLUCAwEAATANBgkqhkiG9w0BAQUFAAOBgQCNm8Uw2a/lSoZBVuf5
      yKx7Ty2ad6NucmN4gfMMpd4WqU7vHX3OTUHSMuuGqsjEJXds7t+QW8k7jUX1X+eV
      TXr8yuhneYjqGLdlXN0/1ywRj1yOEabWsONo8TYkKRVKkf25hrYIvz3S3hT159yn
      RuNsKJB18VhXUCJwurA8bFu0VwA=
      -----END CERTIFICATE-----

      other PEM (base64) encoded certificates can be created without problems.
      If I remove "BEGIN CERTIFICATE", "END CERTIFICATE" tag, decode base64
      and generateCertificate, it works.

      My cert.java program is as follows.

      import java.io.*;
      import java.security.*;
      import java.security.cert.*;
      import java.security.spec.*;
      import java.security.interfaces.*;
      import sun.security.util.*;
      import sun.security.x509.*;
      //import com.initech.iniplugin.IniPluginUtil;
      public class cert {
          private static final String certBeginString="-----BEGIN CERTIFICATE-----";
          private static final String certEndString="-----END CERTIFICATE-----";

          public static void main(String[] args){
              try{
                      FileInputStream fis=new FileInputStream(args[0]);
                      DataInputStream dis=new DataInputStream(fis);

                      CertificateFactory cf=CertificateFactory.getInstance("X.509");
                      byte[] bytes=new byte[dis.available()];
                      dis.readFully(bytes);
                      String decodedCert=new String(bytes);
                      byte[] cc;

                              cc=decodedCert.getBytes();

                      ByteArrayInputStream bais=new ByteArrayInputStream(cc);
                      X509Certificate
      cert=(X509Certificate)cf.generateCertificate(bais);
                      System.out.println(cert.toString());
              }catch(Exception e){
                  System.out.println(e);
              }
          }
      }
      (Review ID: 102706)
      ======================================================================

            mullan Sean Mullan
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: