-
Notifications
You must be signed in to change notification settings - Fork 722
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
feat: add async cert validation support #5110
Merged
Merged
+218
−39
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
goatgoose
reviewed
Feb 12, 2025
goatgoose
reviewed
Feb 14, 2025
goatgoose
approved these changes
Feb 17, 2025
lrstewart
reviewed
Feb 18, 2025
lrstewart
approved these changes
Feb 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Release Summary:
Adds async support to
s2n_cert_validation_callback
Description of changes:
The async validation function should throw an
S2N_ERR_ASYNC_BLOCKED
error when neithers2n_cert_validation_accept()
ors2n_cert_validation_reject()
are called by the validation callback. After the application finishes processing and updates the callback status (i.e. thecert_validation_info
struct) using either API, the application can retry the handshake and complete the validation. To implement this feature, we should consider how to handle the re-entry case. Below are the changes I made:cert_validation_info
struct intos2n_x509_validator
to extend its lifetime, so we can update or check the status after the callback is finished.cert_validation_cb_invoked
ins2n_x509_validator
to identify a re-entry as well as a helper functions2n_x509_validator_handle_cert_validation_callback_result()
to check the callback status (e.g. ifcert_validation_info.finished
is false, bail withS2N_ERR_ASYNC_BLOCKED
).s2n_x509_validator_validate_cert_chain()
. On the re-entry case, we only check callback status and do not repeat the validation process.s2n_handle_retry_state()
, which invokess2n_server_cert_recv()
ors2n_client_cert_recv()
without updating the stuffer read cursor. It may causestuffer out of data
while retrying these two functions. One solution is to copy the stuffer fromconn->handshake.io
and restore it after the validation is completed.Testing:
Confirmed the self-talk unit tests passed both on the client side and on the server side.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.