8000 Verify leaf certificate public key rather then leaving it to the caller by skmcgrail · Pull Request #2438 · aws/aws-lc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Verify leaf certificate public key rather then leaving it to the caller #2438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025

Conversation

skmcgrail
Copy link
Member
@skmcgrail skmcgrail commented May 23, 2025

OpenSSL's behavior when performing X509 certificate validation is to build the up certificate chain, verify the extensions of the constructed chain, etc, finally proceeding with handling the subjectPublicKeyInfo algorithm and parameters inheritance as appropriate through the chain when applicable per rfc5280. This process will cause OpenSSL to reject certificates when encountering public keys that it doesn't understand, for example unknown / unsupported EC curve names, invalid curve points etc. This includes intermediate and root certificates with such public keys (which would need to be usable to validate the issuer signatures on subjects in the chain etc), but also includes the leaf certificate as it's public key is parsed to determine if it inherits parameters etc.

For AWS-LC this parameter inheritance is not supported (as it was removed by BoringSSL from which we forked), particularly because for key types like EC we only support specific named curves and no custom parameters. So this step of key inheritance does not occur. This means that the certificate subject public keys are not used until validating the issuer signatures through the chain. Root and intermediate certificates with public keys that are not parseable / supported are then rejected at this step, except for the leaf certificate. There was a comment left by BoringSSL in the tests to indicate that the subject public key (for which the EVP_PKEY may be NULL if it was not parseable) is left to be validated by the caller invoking X509_verify_cert. This means that such a leaf certificate passes validated (correctly validated through the constructed chain, reasonably well formed etc), but still might not actually be useable. But such certificates would have never returned successfully by X509_verify_cert if using OpenSSL. This PR realigns AWS-LC to behave similarly to OpenSSL by checking the final leaf certificate for the user, and verifying that it contains a supported public key type.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link
codecov-commenter commented May 23, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.83%. Comparing base (12c07b0) to head (04b517f).

Files with missing lines Patch % Lines
crypto/x509/x509_txt.c 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             x509    #2438      +/-   ##
==========================================
- Coverage   78.85%   78.83%   -0.03%     
==========================================
  Files         622      622              
  Lines      108188   108196       +8     
  Branches    15359    15361       +2     
==========================================
- Hits        85314    85298      -16     
- Misses      22220    22245      +25     
+ Partials      654      653       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skmcgrail skmcgrail marked this pull request as ready for review May 23, 2025 23:24
@skmcgrail skmcgrail requested a review from a team as a code owner May 23, 2025 23:24
@skmcgrail skmcgrail merged commit e160630 into aws:x509 Jun 5, 2025
111 of 113 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0