Skip to content

fix: add recurrent TLS close_notify shutdown - #14

Merged
kentbull merged 1 commit into
release/v0.6.20from
p0/recurrent-tls-close-v0.6.20
Aug 27, 2026
Merged

kentbull merged 1 commit into
release/v0.6.20from
p0/recurrent-tls-close-v0.6.20

Conversation

@kentbull

@kentbull kentbull commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Add recurrent ClientTls and RemoterTls shutdown through SSLSocket.unwrap().
  • Drain accepted output and reject writes after close begins.
  • Recur through WANT_READ and WANT_WRITE.
  • Preserve TLS-buffered and final peer plaintext.
  • Force-close failed sessions and dispose of the raw socket returned by successful unwrap().
  • Route directional shutdown aliases through the same TLS operation.

Why

Closing the underlying socket directly can truncate accepted output and bypass authenticated TLS shutdown. A nonblocking endpoint cannot assume OpenSSL completes shutdown in one scheduler cycle.

Background

SSLSocket.unwrap() drives OpenSSL's shutdown state and returns the underlying socket when that operation completes. The protocol meaning of peer close_notify is version-specific; PR #15 supplies that TLS 1.2 versus TLS 1.3 policy.

Boundary

PR #16 later prevents premature unwrap() retry after a no-progress WANT_READ cycle. Owners remain responsible for recurring close, applying deadlines, and choosing force-close.

Implement nonblocking TLS close as a recurrent unwrap exchange on ClientTls and RemoterTls. The close waits for accepted output, rejects later writes, retries WANT_READ and WANT_WRITE, preserves pending plaintext, bypasses unwrap after fatal transport state, and closes the raw socket returned on success.

Route all shutdown entry points through that exchange without hiding TLS errors. Negotiated TLS 1.2 versus 1.3 behavior after peer close_notify remains a separate policy PR.
@kentbull
kentbull merged commit 19064c1 into release/v0.6.20 Aug 27, 2026
6 checks passed
@kentbull
kentbull deleted the p0/recurrent-tls-close-v0.6.20 branch August 27, 2026 10:59
@kentbull

Copy link
Copy Markdown
Collaborator Author

Upstream prerequisites: #11-equivalent clean-versus-truncated TLS receive classification, #12-equivalent terminal TLS send handling, and #13-equivalent recurrent close ownership, all implemented against the accepted directional-state contract.

With those merged, SSLSocket.unwrap() can be driven recurrently through WANT states while preserving queued output and pending plaintext and disposing of the returned raw socket safely.

@kentbull kentbull changed the title fix: complete TLS close_notify without dropping data fix: add recurrent TLS close_notify shutdown Aug 28, 2026
@kentbull

Copy link
Copy Markdown
Collaborator Author

Implements the primary downstream fix for ioflo#176: recurrent TLS close_notify shutdown through SSLSocket.unwrap(), including output settlement, WANT handling, pending-plaintext preservation, late-write rejection, fatal-error handling, and safe disposal of the returned raw socket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant