Repository navigation
[ADR40] TLS mismatch: close the connection after a full round of mismatches; tlsFirst selects the default context - #1665
Conversation
…tlsFirst selects the default context - A TLS mismatch between the options and a server still fails that attempt with the same message, "SSL required by server." or "SSL connection wanted by client.", and the next server is tried, since a single server can be misconfigured. - The options decide TLS for every server of a connection, so when every attempt of one full round over the server list fails with the mismatch, retrying cannot help. The initial connect then closes the connection and throws, also with reconnect-on-connect, instead of entering the reconnect loop. A reconnect round in which every attempt was a mismatch ends with the connection closed. A server that cannot be reached is not a mismatch, so a round that contains one is inconclusive and the normal reconnect rules apply. - tlsFirst() without any other TLS setting selects SSLContext.getDefault() in build(), the same as secure(). The "SSL context required for tls handshake first" error remains only for an SSLContextFactory that returns null. - README "TLS client versus server checks" and docs/TLS_CONFIGURATION.md rules 5 to 8 describe both. - Tests: TLSConnectTests for every-server mismatch (both kinds), one misconfigured server, a mismatch next to an unreachable server, and a reconnect into a server that now requires TLS; OptionsTests for tlsFirst.
|
Claude finished @scottf's task in 3m 57s —— View job Review of PR #1665
SummaryBoth changes are implemented correctly and the control-flow reasoning checks out against the test cases.
No correctness, security, or thread-safety issues found. Tests look like they exercise the specific new branches (closing after one round, mismatch-then-working-server ordering in both directions, inconclusive rounds, reconnect-time mismatch, |
Follows #1663, now merged. Replaces #1664, which GitHub closed when the base branch was deleted. Two changes to how the client handles TLS between the options and the servers.
A full round of TLS mismatches closes the connection. A mismatch between the options and a server still fails that attempt with the same message as before, "SSL required by server." when the options have no SSL context and the server requires TLS, or "SSL connection wanted by client." when the options have a context and the server offers no TLS, and the next server is tried, since a single server can be misconfigured. The options decide TLS for every server of a connection, so when every attempt of one full round over the server list fails with the mismatch, retrying cannot help. The initial connect then closes the connection and throws an
IOExceptionthat starts with the mismatch text and says the connection was closed without retrying, also with reconnect-on-connect, instead of entering the reconnect loop. A reconnect round in which every attempt was a mismatch ends with the connection closed. A server that cannot be reached is not a mismatch, so a round that contains one is inconclusive and the normal reconnect rules apply. The round in the reconnect loop is detected the same way the reconnect delay handler detects it. Error listeners see one exception per attempt, as before, so a client whose every server requires TLS now reports one exception per server instead of one per retry.tlsFirst()asks for TLS. Without any other TLS setting it selectsSSLContext.getDefault()inbuild(), the same assecure(), instead of failing with "SSL context required for tls handshake first". That error remains only for anSSLContextFactorythat returns null. A supplied context, keystore and truststore,opentls()or anopentls://url still take precedence.Docs: README "TLS client versus server checks" keeps its table and gains the round rule;
docs/TLS_CONFIGURATION.mdrules 5 to 8.Tests,
TLSConnectTests: two servers that require TLS without a context, and two plain servers with a context, each close and throw after one attempt per server with no reconnect wait; a server that requires TLS next to a plain one, in both orders, connects to the matching server; a server that requires TLS next to an unreachable port keeps reconnecting until the budget is used; a connected client whose single server starts requiring TLS closes after one reconnect attempt with reconnects remaining;tlsFirst()without a context connects to ahandshake_firstserver.OptionsTestscovers thetlsFirst()context selection. The two closing tests fail on the base branch.