Repository navigation
Conversation
… is set `clickhouse client --secure --host <service> --tls-sni-override <name>` failed with `Unacceptable certificate from <name>: application verification failure` when the server certificate names `<service>` but not `<name>`, which is the documented replica-aware routing setup (the certificate covers `<host>`, the SNI carries `<workload>.sticky.<host>`). Poco kept one name per client socket, `_peerHostName`, and used it both as the SNI value and as the name the certificate is verified against. `Connection` put the override there to get it into SNI, so the override became the only verification name. That was harmless while the client default was `extendedVerification = false`; ClickHouse#116724 turned the name check on for clients and exposed it. Poco now keeps the SNI name separately (`setServerNameIndication`, and an `attach` overload for the socket the port probe hands over), and both secure `Connection` paths set the peer host name to `--host` and the SNI name to the override. With an override, the certificate is first checked against it exactly as before, including the loopback exemption; if that fails, it is accepted when it names the host connected to. The accepted set is therefore master's plus "the certificate names the host that was connected to", the invariant ClickHouse#116724 introduced; nothing master rejects for another reason is accepted. The host fallback is a plain name match without the loopback exemption: with `--host localhost --tls-sni-override <svc>` (an SSH tunnel) master verifies the certificate against `<svc>`, and an exempt fallback would accept any CA-signed certificate on such an endpoint. Sockets that never set a server name (server-accepted sockets, Keeper, HTTPS sessions) run the old code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the new Poco SNI API docs to one line each, drop the duplicated accept-set note on verifyPeerCertificate() and the self-evident matchPeerCertificate() doc. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Workflow [PR], commit [db4fd87] Summary: ❌
AI ReviewSummaryThis PR fixes a real client regression introduced when hostname verification was enabled by default: Final Verdict
|
azat
left a comment
There was a problem hiding this comment.
I am not sure that this is a good idea
- now certificate for
--hostwill work, which open some "opportunities" - and it will work only in clickhouse-client
But honestly I don't understand why this is required sticky routing has wildcard certificates
Without `--port` and `--secure` the client probes both ports and the `Connection` takes over the probed socket (`Connection::adoptSocket`), the second secure path the fix changes. Plain port 0 always refuses, so the probe picks the secure port. One case checks the certificate is accepted for `--host` there (the trace line proves the socket was reused), the other that the reused socket carries the override as its server name: without it the loopback exemption would accept `127.0.0.1`. Reverting only the `adoptSocket` change, or only the `setServerNameIndication` call in the new `attach` overload, fails exactly one of them. Also write `setServerNameIndication` without parentheses in its comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Why it is needed: the Cloud certificates are one-label wildcards. In crt.sh, every unexpired certificate for On your two points:
If that trade-off is not acceptable, the fix belongs in the certificate: cover the sticky names, which also fixes every other driver, and I close this PR. Which do you prefer? |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Looks like we fixed the problem in the meantime by reverting the culprit PR: #125569 |
Related: #116724
Related: #119544
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
clickhouse client --secure --tls-sni-override <name>failing withUnacceptable certificate from <name>when the server certificate names the host given in--hostbut not the override, as in the ClickHouse Cloud replica-aware routing example. Since server certificate hostnames are verified by default, the override was the only name checked; now a certificate that names either the override or the host is accepted.Description
On 26.9.9.28 (also 26.8.18.2 and 26.3.42.3),
clickhouse client --secure --host <service> --tls-sni-override <name>fails withCode: 210 ... Unacceptable certificate from <name>: application verification failurealthough the server certificate names<service>. This breaks the documented replica-aware routing example (--tls-sni-override my-workload-1.sticky.<host>, where the certificate covers only<host>). 26.8.2.7, from before the #116724 backport, connects.Poco used one field,
_peerHostName, both as the SNI value and as the name the certificate is verified against, so the override became the only verification name. #116724 turned the name check on for clients, which exposed it.Poco now keeps the SNI name separately (
setServerNameIndication, plus anattachoverload for the socket the port probe hands over), and both secureConnectionpaths use it. With an override, the certificate is checked against it exactly as before; if that fails, it is accepted when it names the host connected to, by a plain name match without the loopback exemption (a--host localhosttunnel still needs a certificate that names the override orlocalhost).Verifying only
--hostwould break the other documented use: #116724's changelog tells users whose endpoint the certificate does not name (an IP address, for example) to pass--tls-sni-overridewith the name the certificate was issued for, andtest_accept_invalid_certificateandtest_ssl_cert_authenticationpin that setup. Both setups now work, and nothing that master rejects for another reason is accepted.05366_client_tls_sni_override_verifies_hostfails on master and passes with the fix; it also checks that a certificate naming neither name is still rejected.Workflow [PR]
Sync PR [sync-upstream/pr/125407]