-
Notifications
You must be signed in to change notification settings - Fork 724
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
Add API method to get 'hypothetical' alerts #3171
Conversation
Benchmark report |
S2N_TLS_ALERT_CERTIFICATE_REQUIRED = 116, | ||
S2N_TLS_ALERT_NO_APPLICATION_PROTOCOL = 120, | ||
} s2n_tls_alert_code; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the alerts didn't transfer over. Where did S2N_TLS_ALERT_DECOMP_FAILED go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only added the alerts as of TLS1.3. Some old alerts were dropped in TLS1.3. We can add them back if we need them, but they weren't previously being used.
@@ -138,6 +139,15 @@ int test_count; | |||
RESET_ERRNO(); \ | |||
} while(0) | |||
|
|||
#define EXPECT_FAILURE_WITH_ALERT( function_call, err, alert ) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great idea!
Benchmark report |
Description of changes:
For extra security, s2n-tls sends generic close_notify alerts instead of specific TLS alerts.
However, some QUIC interop/compliance tests require specific alerts. Customers might also appreciate knowing what alert an error corresponds to, although alerts should generally be less specific than s2n-tls errors. Additionally, proving compliance with the TLS RFCs would be easier if we could enforce that a specific alert would be sent if we didn't just send a generic close_notify.
I added a new method to the s2n_quic_support APIs to "translate" connection errors into "protocol" / "hypothetical" TLS alerts. For now it mostly just returns internal_error, but we can add more mappings in the future and enforce that new protocol errors include a mapping.
Call-outs:
Should the new method handle all error types, or just S2N_ERR_T_PROTO? Technically only protocol errors should map to alerts. There's also already an existing "s2n_connection_get_alert" method that returns an alert sent by the peer, if it exists. However, forcing customers to branch on the error type to call different methods seems like a poor user experience, so I'd prefer if s2n handles the branching.
Why not add all the alert mappings immediately? Our protocol errors are a bit of a mess. Some of the current protocol errors don't correspond to actual protocol errors / alerts and will need to be changed to internal errors. Additionally, some code will need to be changed to return different errors /alert in order to match the RFC. To keep this initial code change simple, I stuck to just the first two alerts that QUIC implementations are interested in.
Testing:
Added unit tests for the new API, as well as unit tests to demonstrate how we can enforce RFC alert requirements.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.