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

jarsigner tool tries to cast an implementation of java.security.Principal

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • security-libs



      Name: krC82822 Date: 03/06/2001


      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 implemented my own KeyStoreSpi class, built on IAIK's toolkit (www.iaik.at).
      When calling the jarsigner tool, my own KeyStore is instantiated and the
      methods getCertificateChain(..), getCertificate(..) and getKey(..) are called
      of my KeyStore.

      Later on, I see that there is made a "getIssuerDN()" call to my certificate,
      which is an instance of "iaik.x509.X509Certificate". The "getIssuerDN()"
      returns an object implementing the "java.security.Principal" interface. In my
      case, that is a "iaik.asn1.structures.Name" object. Looking at the exception, I
      see that the constructor of the innner class "Block"
      of "sun.security.util.SignatureFile" tries to cast
      our "iaik.asn1.structures.Name" to another implementation of Principal (let's
      say SunName) instead of creating a new instance of sun's own Principal by doing
      something like:

      SunName sunName = new SunName(issuer.getName());
      The exception I get looks as follows:

      jarsigner error: java.lang.ClassCastException: iaik.asn1.structures.Name
      java.lang.ClassCastException: iaik.asn1.structures.Name
              at sun.security.util.SignatureFile$Block.<init>(SignatureFile.java:137)
              at sun.security.util.SignatureFile.generateBlock(SignatureFile.java:122)
              at sun.security.tools.JarSigner.signJar(JarSigner.java:552)
              at sun.security.tools.JarSigner.run(JarSigner.java:108)
              at sun.security.tools.JarSigner.main(JarSigner.java:48)

      Re. "Impact on User": we can, of course, implement our own KeyStore,
      but we're not able to use it together with the jarsigner tool.
      (Review ID: 116672)
      ======================================================================

            Unassigned Unassigned
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: