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

option -Djava.security.debug=x509,ava breaks special chars

XMLWordPrintable

    • b18
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu 24.04.1 LTS
      Oracle OpenJDK 23.0.2

      A DESCRIPTION OF THE PROBLEM :
      Enabling -Djava.security.debug=x509,ava affects how special characters in certificates are processed. The expected behavior is that debugging should not interfere with the normal encoding of certificate fields.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Step 0:
      Generate a p12 file with a certificate with special characters

      Step 1:
      Compile provided source code
      javac Main.java

      Step 2:
      Run class with
      java -Djava.security.debug=x509,ava Main


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Display the special chars

      ACTUAL -
      No special chars displayed


      ---------- BEGIN SOURCE ----------

      import java.security.cert.X509Certificate;
      import java.io.FileInputStream;
      import java.security.KeyStore;
      import java.security.cert.Certificate;
      import java.util.Enumeration;

      public class Main {
          public static void main(String[] args) throws Exception {
              String p12FilePath = "special_chars.p12";
              String password = "password123";
              KeyStore keyStore = KeyStore.getInstance("PKCS12");
                  // Load the KeyStore (PKCS12 format)
                  try(FileInputStream fis = new FileInputStream(p12FilePath)) {
                      keyStore.load(fis, password.toCharArray());
                      // Iterate through the aliases
                      Enumeration<String> aliases = keyStore.aliases();
                      while (aliases.hasMoreElements()) {
                          // Retrieve and print the certificate
                          Certificate cert = keyStore.getCertificate(aliases.nextElement());
                          X509Certificate x509Cert = (X509Certificate) cert;
                          System.out.println("Subject: " + x509Cert.getSubjectX500Principal().getName());
                      }
                  }
          }
      }

      ---------- END SOURCE ----------

            kthirupattur Koushik Muthukrishnan Thirupattur
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: