Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions crates/stdlib/src/ssl/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,16 +1237,21 @@ fn handle_handshake_complete(
}
} else if conn.wants_write() {
// Send all pending data (e.g., TLS 1.3 NewSessionTicket) to socket
// Best-effort: WantWrite means socket buffer full, pending data will be
// sent in subsequent read/write calls. Don't fail handshake for this.
// Must drain ALL rustls buffer - don't break on WantWrite
while conn.wants_write() {
let tls_data = ssl_write_tls_records(conn)?;
if tls_data.is_empty() {
break;
}
match send_all_bytes(socket, tls_data, vm, None) {
Ok(()) => {}
Err(SslError::WantWrite) => break,
Err(SslError::WantWrite) => {
// Socket buffer full, data saved to pending_tls_output
// Flush pending and continue draining rustls buffer
socket
.blocking_flush_all_pending(vm)
.map_err(SslError::Py)?;
}
Err(e) => return Err(e),
}
}
Expand All @@ -1256,6 +1261,7 @@ fn handle_handshake_complete(
// TLS 1.3 Finished must reach server before handshake is considered complete
// Without this, server may not process application data
if !socket.is_bio_mode() {
// Flush pending_tls_output to ensure all TLS data reaches the server
socket
.blocking_flush_all_pending(vm)
.map_err(SslError::Py)?;
Expand Down
Loading