You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "michael-o (via GitHub)" <gi...@apache.org> on 2023/10/30 10:51:29 UTC

[PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

michael-o opened a new pull request, #675:
URL: https://github.com/apache/tomcat/pull/675

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "aooohan (via GitHub)" <gi...@apache.org>.
aooohan commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1377262792


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   I still think it's better to just return it, because the place where the method is called already makes it clear where there is a problem with the OID. (encryption algorithm with OID or pseudo random function with OID etc.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "aooohan (via GitHub)" <gi...@apache.org>.
aooohan commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1376990387


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   I think this only need to return a hex string of `oidBytes` if it does not follow format as the message in GSSException only show a tip 'Improperly formatted ASN.1 DER encoding for Oid' which not help.
   ```suggestion
                   return HexUtils.toHexString(oidBytes)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "aooohan (via GitHub)" <gi...@apache.org>.
aooohan commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1377275894


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   Yes. ; )



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1376474963


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -56,6 +56,8 @@
 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;

Review Comment:
   It has been present for the past 15 years. I am using that class in my code for 10+ years. They are default. Azul, Temurin, OpenJDK, Oracle, HPE JVMs have it. The SPNEGO authenticator is using it as well: https://github.com/apache/tomcat/blob/9b3c28da7ec8ddbd721b127f7f3b0a7d475ab797/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java#L42-L46
   I consider it safe to use.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1376474963


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -56,6 +56,8 @@
 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;

Review Comment:
   It has been present for the past 15 years. I am using that class in my code for 10+ years. They are default. Azul, Temurin, OpenJDK, Oracle, HPE JVMs have it. The SPNEGO authenticator is using it as well: https://github.com/apache/tomcat/blob/9b3c28da7ec8ddbd721b127f7f3b0a7d475ab797/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java#L46
   
   I consider it safe to use.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1377209435


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   I am fine with either. What about:
   ``
   throw new IllegalArgumentException(e.getMajorString() + ": " + HexUtils.toHexString(oidBytes));
   ```
   Combining both. WDYT?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1377274168


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   I see, right. Then it is the user's problem to investigate the file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "aooohan (via GitHub)" <gi...@apache.org>.
aooohan commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1376990387


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   I think this only needd to return a hex string of `oidBytes` if it does not follow format as the message in GSSException only show a tip 'Improperly formatted ASN.1 DER encoding for Oid' which will not help.
   ```suggestion
                   return HexUtils.toHexString(oidBytes)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "aooohan (via GitHub)" <gi...@apache.org>.
aooohan commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1376990387


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   I think this only needs to return a hex string of `oidBytes` if it does not follow format as the message in GSSException only show a tip 'Improperly formatted ASN.1 DER encoding for Oid' which will not help.
   ```suggestion
                   return HexUtils.toHexString(oidBytes)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1377209435


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -624,6 +626,16 @@ private byte[] fromHex(String hexString) {
             }
             return bytes;
         }
+
+
+        private String toDottedOidString(byte[] oidBytes) {
+            try {
+                Oid oid = new Oid(oidBytes);
+                return oid.toString();
+            } catch (GSSException e) {
+                throw new IllegalArgumentException(e.getMajorString());

Review Comment:
   I am fine with either. What about:
   ```
   throw new IllegalArgumentException(e.getMajorString() + ": " + HexUtils.toHexString(oidBytes));
   ```
   Combining both. WDYT?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "rmaucher (via GitHub)" <gi...@apache.org>.
rmaucher commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1377379112


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -56,6 +56,8 @@
 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;

Review Comment:
   I agree it is safe enough.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "ChristopherSchultz (via GitHub)" <gi...@apache.org>.
ChristopherSchultz commented on code in PR #675:
URL: https://github.com/apache/tomcat/pull/675#discussion_r1376435849


##########
java/org/apache/tomcat/util/net/jsse/PEMFile.java:
##########
@@ -56,6 +56,8 @@
 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;

Review Comment:
   Where is this package sourced? It appears to be present in the JRE since at least 1.7. Interpreting the OID bytes in dotted-notation isn't very difficult. If it avoids adding a dependency or relying on a non-mandatory JRE package, I'd prefer a private implementation. If all JREs are required to provide this package, than it's safe to use IMO.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o closed pull request #675: BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs
URL: https://github.com/apache/tomcat/pull/675


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] BZ 67926: PEMFile prints unidentifiable string representation of ASN.1 OIDs [tomcat]

Posted by "michael-o (via GitHub)" <gi...@apache.org>.
michael-o commented on PR #675:
URL: https://github.com/apache/tomcat/pull/675#issuecomment-1787001486

   Merged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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