-
Notifications
You must be signed in to change notification settings - Fork 281
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
Throw SSLException if SSLEngine inbound is closed before outbound. #845
Draft
prbprbprb
wants to merge
2
commits into
google:master
Choose a base branch
from
prbprbprb:engine_close_inbound
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
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 don't think the documentation indicates at all that this will throw
SSLException
if you don't callcloseOutbound
first. This will probably cause you a lot of app compat headaches; it's already difficult enough for app developers to useSSLEngine
correctly and this seems to add to the gotchas.Also concerning is that the stated reason for throwing does not seem to be covered:
Is this handled implicitly by the state transitions in reaction to BoringSSL's signal that it received end-of-stream from the other side?
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.
Yeah, my wording is a poor there, I'll fix it... I carried it over from the bug report.
Both peers are required to send close alerts at the end of the application data stream and not to close their inbound connection until they have received one from the peer. RFC 5246 also states that on receipt of a close alert, the connection transitions to fully closed and sends its own alert and "If the application protocol will not transfer any additional data, but will only close the underlying transport connection, then the implementation MAY choose to close the transport without waiting for the responding close_notify", which is what ConscryptEngine does.
So, if an app has called closeOutbound or a close alert has been received from the peer then it's OK to call closeInbound. The bulk of the tests codify that, but need better wording/docs I think.
However I didn't realise the spec changed for TLS 1.3 and now says "Each party MUST send a "close_notify" alert before closing its write side of the connection, unless it has already sent some error alert. This does not have any effect on its read side of the connection. Note that this is a change from versions of TLS prior to TLS 1.3 in which implementations were required to react to a "close_notify" by discarding pending writes and sending an immediate "close_notify" alert of their own" - that doesn't change the requirement to send a close_notify before closing the inbound connection, but it might mean we need to revisit the way we respond to incoming close alerts in a future change.
And of course this is related to PR #844 where ConscryptEngineSocket prevents the close alerts from flowing anyway by closing the underlying socket too soon.
Agree about app compat issues though, and so this change should be gated in some way. I'm designing something so we can gate on targetSdkLevel in the Android platform and some other criterion (using the same Annotations) on other platforms. Meanwhile I'll move most of the tests to a separate PR and clarify the wording.