RFR: 8325766: Review seclibs tests for cert expiry [v4]
Matthew Donovan
mdonovan at openjdk.org
Tue Jun 3 13:18:01 UTC 2025
On Fri, 30 May 2025 19:28:27 GMT, Sean Mullan <mullan at openjdk.org> wrote:
>> Matthew Donovan has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits:
>>
>> - expanded wildcard imports
>> - Merge branch 'master' into certbuilder
>> - Merge branch 'master' into certbuilder
>> - reversed order of DN strings when making certificates.
>> - Merge branch 'master' into certbuilder
>> - Merge branch 'master' into certbuilder
>> - Merge branch 'master' into certbuilder
>> - Merge branch 'master' into certbuilder
>> - changed boolean array initialization
>> - 8325766: Review seclibs tests for cert expiry
>
> test/lib/jdk/test/lib/security/CertificateBuilder.java line 109:
>
>> 107: */
>> 108: public static CertificateBuilder newCertificateBuilder(String subjectName,
>> 109: PublicKey publicKey, PublicKey caKey, KeyUsage... keyUsages)
>
> My suggestion is to make this a regular constructor and have an additional method that sets the certificate lifetime as a `Duration` parameter, ex:
>
> `new CertificateBuilder(subject, pubKey, caPubKey, keyUsage).withValidity(Duration.ofHours(1));`
I think the way it currently is follows the builder pattern better. All of the 'set' methods return `this` which means if I change this method to a constructor, I'd have to duplicate the "set" code from all those methods.
I like the idea of using `Duration` but the API for it doesn't really lend itself to this use case. When the certificate is finally created, we write `Date` objects to the DerOutputStream so I'd have to choose a start time and then calculate the end time based on the duration. It's not hard, but it doesn't seem worth it when the common use case of this class is to generate short-lived certificates for a test. The default one-hour validity will cover the vast majority of tests.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23700#discussion_r2123779281
More information about the security-dev
mailing list