test: add test certs for cert intent validation #5630
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.
Goal
Adds new test certificates that will be used to test the certificate intent validation
Why
Uploading a ton of test certs contributes to a huge PR. Thus, I separated it from the next PR that will officially enable the cert intent validation.
How
The test certificates being added are a bit complex, since they can't be self signed (s2n-tls won't validate the intent of trust anchors) and the extensions of individual certs in the chain need be modified. Hence, this PR adds a Python script to generate different combinations of the KeyUsage (KU) and ExtendedKeyUsage (EKU) extensions.
Changes overview:
CertChainBuilderclass that takes a list ofCertConfigand invokes Python’s x509 module to build a certificate chain. EachCertConfigincludes an array ofExtensionConfig, which represents a KU/EKU extension of an individual cert in the chain.build()method to construct the cert chain (e.g. the current cert must be issued by the previous cert in the chain) and awrite()method to store each individual cert, the cert chain, and the private key to a pem file.generate.pyto iterate over all the combinations of KU and EKU extensions that will be tested against the cert intent validation API and generate the test certs.Testing
This PR does not affect existing behaviors. CI should pass.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.