JSSE: fix SSLEngine.unwrap() data delivery and close_notify handling after closeOutbound()#379
Open
cconlon wants to merge 1 commit into
Open
JSSE: fix SSLEngine.unwrap() data delivery and close_notify handling after closeOutbound()#379cconlon wants to merge 1 commit into
cconlon wants to merge 1 commit into
Conversation
…se_notify after closeOutbound()
There was a problem hiding this comment.
Pull request overview
This PR adjusts WolfSSLEngine.unwrap() behavior after closeOutbound() so that, when inbound is still open and the handshake is complete, unwrap continues through the normal receive path to deliver any pending peer application data and process the peer’s close_notify (preventing hangs in close loops). It also adds a regression test that reproduces the SunJSSE interop close sequence that previously could spin indefinitely.
Changes:
- Update
WolfSSLEngine.unwrap()to only route intoClosingConnection()when inbound is already closed or the handshake is not finished, avoiding discarding buffered application data aftercloseOutbound(). - Add
testCloseOutboundWithPendingAppDatato validate app-data delivery during close and ensure both engines fully close within a bounded wrap/unwrap loop.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/java/com/wolfssl/provider/jsse/WolfSSLEngine.java |
Refines unwrap shutdown routing so inbound app-data and peer close_notify are still processed after closeOutbound() when appropriate. |
src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java |
Adds a regression test covering the close sequence with pending app data to prevent hangs and silent data loss. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
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.
This PR fixes a hang in the SunJSSE interop test
SSLEngine/NoAuthClientAuth.javawhen wolfJSSE is run against wolfSSL master containing 07d4174 (wolfSSL/wolfssl#10863), along with silent discarding of application data received aftercloseOutbound().Problem
When an application calls
SSLEngine.closeOutbound()while inbound is still open,unwrap()routed all processing throughClosingConnection()/wolfSSL_shutdown(). This caused two issues:closeOutbound()were decrypted into native wolfSSL's internal buffer but never delivered to the application (silently discarded).wolfSSL_shutdown()returnsWOLFSSL_SHUTDOWN_NOT_DONEwithout processing incoming records while decrypted application data is still buffered. With unread data pending, the peer's close_notify was never processed,isInboundDone()never returned true, and applications looping on engine close status spun forever.The
NoAuthClientAuth.javaclose sequence (servercloseOutbound()while the client still sends application data followed by close_notify) hits exactly this state.Fix
Only route
unwrap()intoClosingConnection()when inbound is already closed or the handshake is not finished. Otherwise fall through to the normal receive path, which delivers pending application data and processes the peer's close_notify viaRecvAppData().The
WolfSSLSocketpath is unaffected: it makes a singlewolfSSL_shutdown()call per connection (unidirectional close), never reaching the bidirectional branch where the native pending-data check lives.Testing
Added
testCloseOutboundWithPendingAppDatatoWolfSSLEngineTest: drives two engines through the NoAuthClientAuth close sequence with a bounded wrap/unwrap loop, asserting app data sent during close is delivered and both engines fully close.