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

KeyStore PKCS12 does not return stored certificate by alias if alias contains up

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 8, 9
    • security-libs

      FULL PRODUCT VERSION :
      java version "1.8.0_31"
      Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin tanelorn 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      KeyStore PKCS12 does not return stored certificate by alias if alias contains upper case characters.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create KeyStore:
      KeysStore keyStore = KeyStore.getInstance("PKCS12");

      Store certificate:
      keyStore.setCertificateEntry("testCert", certificate);

      Get Certificate don't work:
      keyStore.getCertificate("testCert"); // null

      boolean a = keyStore.entryInstanceOf("testCert", KeyStore.PrivateKeyEntry.class); // false
      a = keyStore.entryInstanceOf("testCert", KeyStore.TrustedCertificateEntry.class); // false
      a = keyStore.entryInstanceOf("testCert", KeyStore.SecretKeyEntry.class); // false

      keyStore.getEntry("testCert", new KeyStore.PasswordProtection(password)); // null

      keyStore.aliases(); // contain "testCert"

      keyStore.containsAlias("testCert"); // false



      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      package sun.security.pkcs12;

      trouble in PKCS12KeyStore.class

          public boolean engineContainsAlias(String var1) {
              return this.entries.containsKey(var1.toLowerCase(Locale.ENGLISH));
          }

      because in setCertEntry at this.entries.put(var1, var5);
      var1 not lower cased;


            vinnie Vincent Ryan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: