[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-dev
Subject:    (tomcat) branch main updated: BZ 67926: PEMFile prints unidentifiable string representation of ASN.1
From:       michaelo () apache ! org
Date:       2023-10-31 11:07:03
Message-ID: 169875042344.1686555.15463629994246637483 () gitbox2-he-fi ! apache ! org
[Download RAW message or body]

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 3151ed38a6 BZ 67926: PEMFile prints unidentifiable string representation of \
ASN.1 OIDs 3151ed38a6 is described below

commit 3151ed38a65a77f0bb2ef9668bd19ceb5f31c48a
Author: Michael Osipov <michaelo@apache.org>
AuthorDate: Mon Oct 30 11:43:36 2023 +0100

    BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs
---
 java/org/apache/tomcat/util/net/jsse/PEMFile.java | 20 ++++++++++++++++----
 webapps/docs/changelog.xml                        |  4 ++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/jsse/PEMFile.java \
b/java/org/apache/tomcat/util/net/jsse/PEMFile.java index b3f60ce0db..5bef5b6f24 \
                100644
--- a/java/org/apache/tomcat/util/net/jsse/PEMFile.java
+++ b/java/org/apache/tomcat/util/net/jsse/PEMFile.java
@@ -56,6 +56,8 @@ import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.codec.binary.Base64;
 import org.apache.tomcat.util.file.ConfigFileLoader;
 import org.apache.tomcat.util.res.StringManager;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.Oid;
 
 /**
  * RFC 1421 PEM file containing X509 certificates or private keys.
@@ -375,7 +377,7 @@ public class PEMFile {
                      */
                     if (!Arrays.equals(oidEncryptionAlgorithm, OID_PBES2)) {
                         throw new \
                NoSuchAlgorithmException(sm.getString("pemFile.unknownPkcs8Algorithm",
                
-                                HexUtils.toHexString(oidEncryptionAlgorithm)));
+                                toDottedOidString(oidEncryptionAlgorithm)));
                     }
 
                     // PBES2-params
@@ -388,7 +390,7 @@ public class PEMFile {
                     byte[] oidKDF = p.parseOIDAsBytes();
                     if (!Arrays.equals(oidKDF, OID_PBKDF2)) {
                         throw new NoSuchAlgorithmException(
-                                sm.getString("pemFile.notPbkdf2", \
HexUtils.toHexString(oidKDF))); +                                \
sm.getString("pemFile.notPbkdf2", toDottedOidString(oidKDF)));  }
 
                     // PBES2 KDF-params
@@ -406,7 +408,7 @@ public class PEMFile {
                     byte[] oidPRF = p.parseOIDAsBytes();
                     String prf = OID_TO_PRF.get(HexUtils.toHexString(oidPRF));
                     if (prf == null) {
-                        throw new \
NoSuchAlgorithmException(sm.getString("pemFile.unknownPrfAlgorithm", \
HexUtils.toHexString(oidPRF))); +                        throw new \
NoSuchAlgorithmException(sm.getString("pemFile.unknownPrfAlgorithm", \
toDottedOidString(oidPRF)));  }
                     p.parseNull();
 
@@ -417,7 +419,7 @@ public class PEMFile {
                     Algorithm algorithm = \
OID_TO_ALGORITHM.get(HexUtils.toHexString(oidCipher));  if (algorithm == null) {
                         throw new NoSuchAlgorithmException(
-                                sm.getString("pemFile.unknownEncryptionAlgorithm", \
HexUtils.toHexString(oidCipher))); +                                \
sm.getString("pemFile.unknownEncryptionAlgorithm", toDottedOidString(oidCipher)));  }
 
                     byte[] iv = p.parseOctetString();
@@ -624,6 +626,16 @@ public class PEMFile {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                return HexUtils.toHexString(oidBytes);
+            }
+        }
     }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 575b08f3dc..edac7d0e60 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -125,6 +125,10 @@
         support a broader range of environments, and to give better information
         in the event of a failure. (schultz)
       </update>
+      <update>
+        <bug>67926</bug>: <code>PEMFile</code> prints unidentifiable string \
representation +         of ASN.1 OIDs. (michaelo)
+      </update>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic