Compare commits

...

1 Commits

Author SHA1 Message Date
Claude Bot
2b8ba0c568 fix(tls): trigger handshake callback when handshake completes during SSL_read
When SSL_read succeeds and returns application data, the TLS handshake
may have just completed during that call. However, the handshake callback
was only triggered for renegotiation, not for the initial handshake.

Now we check SSL_is_init_finished() to ask OpenSSL directly whether the
handshake is complete, and only then trigger the callback if we haven't
already notified the application.

This fixes a race condition where request.socket._secureEstablished
could be false in HTTPS request handlers under load.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-10 05:23:10 +00:00

View File

@@ -569,8 +569,8 @@ restart:
break;
}
} else if (s->handshake_state == HANDSHAKE_RENEGOTIATION_PENDING) {
// renegotiation ended successfully call on_handshake
} else if (s->handshake_state != HANDSHAKE_COMPLETED && SSL_is_init_finished(s->ssl)) {
// handshake just completed during SSL_read, notify the application
us_internal_trigger_handshake_callback(s, 1);
}