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

OpenSslEngine return NEED_WRAP if the destination buffered filled #6803

Closed
wants to merge 1 commit into from

Conversation

Scottmitch
Copy link
Member

@Scottmitch Scottmitch commented Jun 1, 2017

Motivation:
If the destination buffer is completely filled during a call to OpenSslEngine#wrap(..) we may return NEED_UNWRAP because there is no data pending in the SSL buffers. However during a handshake if the SSL buffers were just drained, and filled up the destination buffer it is possible OpenSSL may produce more data on the next call to SSL_write. This means we should keep trying to call SSL_write as long as the destination buffer is filled and only return NEED_UNWRAP when the destination buffer is not full and there is no data pending in OpenSSL's buffers.

Modifications:

  • If the handshake produces data in OpenSslEngine#wrap(..) we should return NEED_WRAP if the destination buffer is completely filled

Result:
OpenSslEngine returns the correct handshake status from wrap().
Fixes #6796.

@Scottmitch Scottmitch self-assigned this Jun 1, 2017
SSLEngineResult result = wrap(alloc, engine, Unpooled.EMPTY_BUFFER, out);

if (previousNeedUnwrap) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes to SslHandler are just to support debugging and will be removed if this PR is accepted.

@Scottmitch
Copy link
Member Author

@rkapsi - would you mind trying this PR with OPENSSL and report back the same log statements you did as in #6796 (comment)?

@rkapsi
Copy link
Member

rkapsi commented Jun 2, 2017

@Scottmitch - will do first thing in the morning tomorrow

@Scottmitch
Copy link
Member Author

@rkapsi verified this patch works as expected in #6796 (comment)

@Scottmitch Scottmitch added this to the 4.0.48.Final milestone Jun 2, 2017
Copy link
Member

@normanmaurer normanmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.... just remember to remove debug stuff

@Scottmitch
Copy link
Member Author

@rkapsi - Thanks for verifying! I reverted the debug code ... would you mind verifying that #6796 is fixed without any changes to SslHandler?

Motivation:
If the destination buffer is completely filled during a call to OpenSslEngine#wrap(..) we may return NEED_UNWRAP because there is no data pending in the SSL buffers. However during a handshake if the SSL buffers were just drained, and filled up the destination buffer it is possible OpenSSL may produce more data on the next call to SSL_write. This means we should keep trying to call SSL_write as long as the destination buffer is filled and only return NEED_UNWRAP when the destination buffer is not full and there is no data pending in OpenSSL's buffers.

Modifications:
- If the handshake produces data in OpenSslEngine#wrap(..) we should return NEED_WRAP if the destination buffer is completely filled

Result:
OpenSslEngine returns the correct handshake status from wrap().
Fixes netty#6796.
@Scottmitch
Copy link
Member Author

4.1 (24f801c) 4.0 (77bc0f2)

@Scottmitch Scottmitch closed this Jun 2, 2017
@Scottmitch Scottmitch deleted the openssl_wrap_status branch June 2, 2017 14:48
@Scottmitch
Copy link
Member Author

I will pull this in now as even if it doesn't fix #6796 it is still an issue, and the behavior from the log statements provided in #6796 (comment) demonstrates the correct behavior.

@rkapsi
Copy link
Member

rkapsi commented Jun 2, 2017

@Scottmitch running 24f801c built from HEAD of 4.1 now. Looks good, no issues. 💯

Scottmitch added a commit to Scottmitch/netty that referenced this pull request Jun 2, 2017
Motivation:
PR netty#6803 corrected an error in the return status of the OpenSslEngine. We should now be able to restore the SslHandler optimization.

Modifications:
- This reverts commit 7f3b75a.

Result:
SslHandler optimization is restored.
Scottmitch added a commit that referenced this pull request Jul 10, 2017
Motivation:
PR #6803 corrected an error in the return status of the OpenSslEngine. We should now be able to restore the SslHandler optimization.

Modifications:
- This reverts commit 7f3b75a.

Result:
SslHandler optimization is restored.
Scottmitch added a commit that referenced this pull request Jul 10, 2017
Motivation:
PR #6803 corrected an error in the return status of the OpenSslEngine. We should now be able to restore the SslHandler optimization.

Modifications:
- This reverts commit 7f3b75a.

Result:
SslHandler optimization is restored.
liuzhengyang pushed a commit to liuzhengyang/netty that referenced this pull request Sep 10, 2017
Motivation:
PR netty#6803 corrected an error in the return status of the OpenSslEngine. We should now be able to restore the SslHandler optimization.

Modifications:
- This reverts commit 7f3b75a.

Result:
SslHandler optimization is restored.
kiril-me pushed a commit to kiril-me/netty that referenced this pull request Feb 28, 2018
Motivation:
PR netty#6803 corrected an error in the return status of the OpenSslEngine. We should now be able to restore the SslHandler optimization.

Modifications:
- This reverts commit 7f3b75a.

Result:
SslHandler optimization is restored.
pulllock pushed a commit to pulllock/netty that referenced this pull request Oct 19, 2023
Motivation:
PR netty#6803 corrected an error in the return status of the OpenSslEngine. We should now be able to restore the SslHandler optimization.

Modifications:
- This reverts commit 7f3b75a.

Result:
SslHandler optimization is restored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants