RFR: 8296787: Unify debug printing format of X.509 cert serial numbers [v3]

Sean Mullan mullan at openjdk.org
Wed Nov 29 20:54:06 UTC 2023


On Wed, 29 Nov 2023 19:12:20 GMT, Ben Perez <duke at openjdk.org> wrote:

>> Updated `X509CertSelector.java`, `SerialNumber.java`, and `SSLLogger`  to use same debug printing format for X.509 serial numbers. The changes are:
>> -  `X509CertSelector` was `SN: 83be056904246b1a1756ac95991c74a` and now is `Serial number: 08:3B:E0:56:90:42:46:B1:A1:75:6A:C9:59:91:C7:4A`
>> - `SerialNumber` was `SerialNumber: [ 083be056 904246b1 a1756ac9 5991c74a]` and now is `Serial number: 08:3B:E0:56:90:42:46:B1:A1:75:6A:C9:59:91:C7:4A`
>> - `SSLLogger` was `"serial number" : "083BE056904246B1A1756AC95991C74A"` and now is `"serial number" : 08:3B:E0:56:90:42:46:B1:A1:75:6A:C9:59:91:C7:4A`
>
> Ben Perez has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Changed serial number formatting method

src/java.base/share/classes/sun/security/x509/SerialNumber.java line 104:

> 102:      * Return the SerialNumber as user readable string.
> 103:      */
> 104:     public String toString() { return "Serial number: " +

Here I would keep "Serial number" as "SerialNumber" to maintain consistency with other X.509 `toString` methods which generally emit the name of the field using camel case format.

My only other comment is to whether it makes sense to move this into a utility method. I see `sun.security.util.Debug.toString` already does the same thing and uses `HexFormat` but in lower case. I think using lower case or upper case is not a big deal. So maybe just change all of these code instances to call `Debug.toString` to keep things consistent and reuse existing code.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16834#discussion_r1409849893


More information about the security-dev mailing list