feat(dgw): improve system store certificate selection #1341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The selection is now discriminating based on the extended key usage and the not valid before date.
A test was conducted in a setup with the following certificates available in the system store:
0) A certificate valid between today and April 2027 without the server authentication extended usage.1) A certificate valid between today and April 2027 with the server authentication extended usage.2) A certificate valid between today and January 2027 with the server authentication extended usage.3) A certificate valid between May 2027 and May 2028.4) A certificate expired, not valid anymore.Here is an execution trace:
First (
0) is disregarded because it is missing the server authentication extended usage, and (3) is disregarded because it is not yet valid.Then certificates are sorted based on the farthest not after validity date: (
1), (2) and (4).Since (
4) is expired, it ends up at the end of the list.Ultimately (
1) is selected because it has the farthest validity date.For the sake of completeness, here are the certificates: deliciousoden.ninja_certificates.zip
The password on the PFX files is
abc.Issue: DGW-262