Skip to content
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

Save leaf certificate in SSL early to avoid losing external data #1074

Merged
merged 4 commits into from
Jul 6, 2023

Conversation

samuel40791765
Copy link
Contributor

Issues:

Resolves CryptoAlg-1935

Description of changes:

This reverts some of the changes done in 3a2b47a.
AWS-LC/BoringSSL also allows external data to be associated with the X509 structures with the same APIs. However, our SSL connections don't directly save the X509 certificate as a structure within SSL_CTX. We "fold" the certificate and convert it into a binary blob to maintain within SSL_CTX. The certificate is not parsed back into an X509 until the user asks for it.
This creates issues when the user attempts to associate data with the certificate with X509_set_ex_data and passes the certificate into SSL_CTX. The data usually associated is not ASN.1 code, thus non-parsable, and the associated data gets lost during the translation to pure bytes. This creates issues with codebases like nginx, who was associating their own OCSP stapling data structures with X509 structures in SSL_CTX.

I've changed this to cache the leaf certificate early, so that the external data is kept for that cert. The same behavior is kept for the rest of the change. This keeps the changes needed contained and avoids an entire restructure of the use of CRYPTO_BUFFER in CERT.

Call-outs:

This lets us pass more ssl_stapling in nginx. There are some more subtle OCSP changes required, but I'll open another PR for that.

Testing:

CI

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.

ssl/ssl_x509.cc Outdated Show resolved Hide resolved
dkostic
dkostic previously approved these changes Jun 29, 2023
skmcgrail
skmcgrail previously approved these changes Jun 30, 2023
@samuel40791765 samuel40791765 dismissed stale reviews from skmcgrail and dkostic via 00e9f74 June 30, 2023 19:24
dkostic
dkostic previously approved these changes Jul 5, 2023
ssl/ssl_test.cc Outdated Show resolved Hide resolved
@samuel40791765 samuel40791765 enabled auto-merge (squash) July 6, 2023 16:06
@samuel40791765 samuel40791765 merged commit e1ba2b3 into aws:main Jul 6, 2023
@skmcgrail skmcgrail mentioned this pull request Jul 7, 2023
@samuel40791765 samuel40791765 deleted the x509-data-fix branch July 8, 2023 01:25
samuel40791765 added a commit that referenced this pull request Jul 12, 2023
Asides from the behavior fixed in #1074, there were some slight OCSP
errors when building with nginx's OCSP stapling tests. There are still a
couple of tests failing due to us missing multiple certs support, but this
should resolve all other issues with us failing the test.

The NULL check in ocsp_find_signer_sk static function was also a bit
too pedantic, so I relaxed it. It's possible for the OCSP Basic Response
to be missing a cert stack, so we shouldn't be throwing an error on to
the stack if that happens. Also implemented functionality for the two
OCSP flags, OCSP_NOVERIFY and OCSP_TRUSTOTHER
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.

3 participants