Skip to content

Verify the server certificate hostname on outbound TLS connections - #116724

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/tls-verify-outbound-hostname
Sep 20, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:groeneai/tls-verify-outbound-hostname

Conversation

@groeneai

@groeneai groeneai commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Outbound TLS connections now verify that the server certificate names the host that was connected to. This affects clickhouse-client --secure, remoteSecure(), Distributed over the secure native protocol, secure Keeper connections, and HTTPS clients such as s3(), url(), HTTP dictionaries and JWT token endpoints. Connecting to an endpoint whose certificate does not name it, for example an IP address with no matching SAN, an S3-compatible gateway fronted by a different name, or an internal CA with missing SANs, now fails with Unacceptable certificate. Set openSSL.client.extendedVerification to false to restore the previous behaviour, or pass --tls-sni-override to name the host the certificate was issued for. Loopback addresses stay exempt unless verificationMode is strict, and the default for openSSL.server.extendedVerification is unchanged.

Description

Closes: #35504

Outbound TLS connections validated the certificate chain but never checked that the certificate identified the host being connected to, so any CA-signed certificate for any name was accepted for any host.

One literal caused it. SSLManager.cpp:345 defaulted extendedVerification to false, which made verifyPeerCertificateImpl return X509_V_OK before reaching X509_check_host. It is the only place in the NetSSL layer that turns the check off: all three Context constructors default it to true.

The default now depends on the prefix, !server. It must not flip for the server context: on an accepted socket there is no requested host name, so the check would run against the client's address, and a client certificate names a user. I measured that a bare true rejects a CN=client1 certificate with Unacceptable certificate from <client IP>, which would break ssl_certificate authentication; with !server the same mTLS client connects.

Fixing the boundary covers every caller of the default client context. One of them could not benefit: the secure Keeper client never set a peer host name, so it verified the resolved IP rather than the configured host. It now carries the name, which also puts the host into SNI, something that path did not send before.

Four CI sites verify a certificate that does not name the address they dial. Three opt out where peer identity is not what the test is about; test_ssl_cert_authentication instead sets tls-sni-override to the host it already declares.

@ alexey-milovidov asked for this default on #35504, raising it for clickhouse-client, and judged the compatibility risk acceptable there. The issue is unassigned; @ kaijaytu offered to take it on 2026-08-03 and I am happy to hand over.


Workflow [PR]
Sync PR [sync-upstream/pr/116724]

Version info

  • Merged into: 26.10.1.268-master (included in 26.10 and later)
  • Backported to: 26.9.1.1621, 26.8.10.6, 26.7.14.2, 26.3.33.122

Outbound TLS validated the certificate chain but never checked that the
certificate identified the host being connected to, so any CA-signed
certificate for any name was accepted for any host. Reproduced against a
server presenting a certificate for `not-localhost` and reached at a
non-loopback address under a default client configuration: `SELECT 1`
returned `1` before this change and now fails with `Code: 210 ...
Unacceptable certificate from <host>: application verification failure`.

`SSLManager::initDefaultContext(bool server)` picks its prefix at
`SSLManager.cpp:241` and runs once per default context, so the single
`false` default at `:345` reached the default client context as well as
the server one. With extended verification off,
`SecureSocketImpl::verifyPeerCertificateImpl` returns `X509_V_OK` at
`SecureSocketImpl.cpp:465-467` before reaching `X509_check_host` or
`X509_check_ip_asc`, and nothing calls `SSL_set1_host`. That `false` was
the only place in the layer turning the check off: all three `Context`
constructors default `_extendedCertificateVerification(true)`.

The default is now `!server`. It must not flip for the server context.
On an accepted socket `_peerHostName` is empty, so the check runs against
the client's address, while a client certificate names a user. Measured:
with `openSSL.server.extendedVerification` set to `true`, which produces
the same context state a bare `true` would, a client presenting a
`CN=client1` certificate is rejected with `Unacceptable certificate from
10.33.45.204` under `relaxed` and additionally from `127.0.0.1` under
`strict`. That is `ssl_certificate` authentication broken. With `!server`
and the key absent, the same client connects in both modes.

Correcting the boundary covers every caller of the default client
context: pooled HTTPS, the native secure protocol, JWT, and the Silk
socket factory all set a peer host name already. One carrier could not
benefit, so it is fixed here too. `ZooKeeper::connect` built a bare
`SecureStreamSocket` and never called `setPeerHostName`, then connected
to a pre-resolved address, so `verifyPeerCertificate()` fell back to
`peerAddress().host().toString()` and verified the resolved IP. Measured
against a local Keeper over TLS whose certificate names the host by DNS
name only: the same configuration failed with `Unacceptable certificate
from 127.0.1.1` and now succeeds. Carrying the name is also what puts
the host into the SNI extension, which that path did not send.

`node.host` is `"<host>:<port>"`, so the name has to be extracted.
`DB::parseAddress` is not used: it requires a numeric port, and its IPv6
branch keeps the brackets, which `X509_check_host` would never match. The
helper mirrors Poco's own lexical split and never inspects the port, so
no host:port shape that resolves today changes. Verified against
`Poco::Net::SocketAddress` for IPv4, bracketed IPv6, a DNS name and a
port spelled as a service name by reconstructing the input from the
helper's answer and requiring Poco's `port()` to equal an independent
resolution of the remaining suffix. `SocketAddress::host()` is not a
valid oracle here because it returns the resolved address.

`openssl_client_extended_verification` in `ServerSettings.cpp` moves with
the literal. Nothing reads it, but it is the source of the default shown
in `system.server_settings` and in the generated reference page, so
leaving it would publish `false` for behaviour that is `true`.
`SettingsChangesHistory.cpp` holds query settings only and contains no
server settings, so no entry there is possible.

Four CI sites verify a certificate that does not name the address they
dial, out of 71 `openSSL/client` blocks in the tree, 56 of which are
immune because they set `verificationMode` to `none`. Note that
`AcceptCertificateHandler` is not an off switch: it is consulted from
OpenSSL's chain-verify callback, while extended verification throws
directly from `SecureSocketImpl`. `test_ssl_cert_authentication` sets
`tls-sni-override` to the host it already declares in `SSL_HOST`, which
makes its native path agree with the hostname checking it already forces
on its Python path. `test_bind_host` and both `test_acme_tls` configs opt
out, the latter because Pebble's serving certificate names `localhost`,
`pebble` and `127.0.0.1` while the test dials a pinned `10.5.11.2`.

New coverage: three arms in `test_accept_invalid_certificate` using the
existing CA-signed `client-cert.pem`, for a name mismatch being rejected,
`tls-sni-override` being accepted, and `extendedVerification=false`
still being honoured; and one arm in `test_keeper_secure_client` whose
client actually verifies. That suite's `server.crt` had to be regenerated
because it was `CN=localhost` with no SAN while the test connects to
`node1`; the new pair keeps `CN=localhost`, self-signed, `CA:TRUE` and
RSA-2048, adds `subjectAltName = DNS:localhost, DNS:node1`, and
`generate_certs.sh` records how.

Closes: ClickHouse#35504
The shared "Keys for server/client settings" table is a hand-maintained
generator input (`autogenerate_docs.py:185-187` lists it under `deps` and
`global-server-settings.sql:11` reads it with `file(..., RawBLOB)`), so it
carries no autogenerated region and nothing rewrites this cell. Left at
`false` it would contradict the generated per-setting page, which the
nightly derives from the `DECLARE` and will render as `true` for the client
setting, and it would misinform the operators the backward incompatible
changelog entry is aimed at.

The server default is unchanged, so the cell names both.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet labels Aug 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 4 findings over 1 full pass and
1 delta recheck), plus 7 from my own cold review of the resulting code. 1 fix round.

# Sev Finding Verdict Evidence / action
1 ⚠️ The published openSSL settings table still gave the default as false for both prefixes (_server_settings_outside_source.mdx:1171) AGREE, fixed @ 3c90c934 That file is a hand-maintained generator input, not generated output: no AUTOGENERATED marker, autogenerate_docs.py:185-187 lists it under deps, global-server-settings.sql:11 reads it with file(..., RawBLOB). The cell now names both defaults, so the page cannot contradict the generated per-setting entry.
2 ❌ A numeric endpoint can accept a certificate carrying the IP text only as a dNSName SAN or CN, because X509_check_host is tried before IP matching (SecureSocketImpl.cpp:478-487) DISAGREE The call order is real, but that function is unchanged here (the only change in this layer is the default in SSLManager.cpp), and such a certificate does name the connected host in text and must still chain to a trusted CA. That is not the behaviour this PR removes, where a certificate for an unrelated name was accepted, so the change is strictly narrowing. Dispatching IP references exclusively to X509_check_ip would be a second, unannounced incompatible tightening for internal CAs that put the endpoint IP in CN or dNSName, so I did not fold it in.
3 ❌ The non-strict loopback exemption is evaluated against the verification name rather than the connected address, so --tls-sni-override localhost, or a loopback DNS answer, skips the check (SecureSocketImpl.cpp:444-468, :497-508) DISAGREE Also real, also unchanged by this PR. The changelog states the exemption, so it is a documented boundary rather than a broken promise, and strict removes it. The SNI form is an operator waiver equivalent to setting extendedVerification to false. The DNS form needs two divergent resolutions of one name plus a CA-signed certificate, so at worst it leaves the previous behaviour in place for those victims. Keying the exemption on peerAddress().host().isLoopback() is the stronger design and changes behaviour for deployments already running with extendedVerification on, so it wants its own compatibility note.
4 ⚠️ The new Keeper arm stays green if hostname verification becomes a no-op DISAGREE That mutation reddens test_accept_invalid_certificate::test_hostname_mismatch_rejected_by_default, added in this PR: it dials the node by IP against client-cert.pem, which is CN=client with no extensions at all, and asserts Unacceptable certificate. The Keeper arm is live for what it exists to pin: its config omits extendedVerification and dials the non-loopback name node1, so reverting the ZooKeeperImpl change makes it verify the resolved address and fail.
5 💡 7 accuracy findings of my own: maintainer positions quoted at their true scope, the Silk factory supplies no peer host name but has no callers, a line citation, a missing disclosure, programs/server/config.xml prose, and the two commit-message items below AGREE x4 (applied), DISAGREE x3 I did not add extendedVerification prose to the shipped config.xml: the knob is named in the changelog and in the settings table row 1 corrects.

Two corrections to the commit message of 238631e55ec220c, stated here rather than by rewriting
history: the short-circuit return is at SecureSocketImpl.cpp:467-469, not :465-467; and the
sweep denominator it quotes is method dependent, re-measured with the same method as 68
openSSL/client blocks on the base tree and 72 including this PR's own new blocks. The immune
count (56) and the conclusion (four affected CI sites, each handled) both reproduce.

No integration suite could be executed on the machine that prepared this PR, because docker
networking is unavailable there. The new arms were measured locally against those suites' own
fixture certificates on both binaries, so the container plumbing is what CI verifies first.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-9:20260827-125900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, no randomisation involved. A server presenting a certificate for not-localhost, reached at a non-loopback address under a default client configuration: clickhouse client --config-file=client.xml --host <non-loopback IP> --port <secure> --secure -q "SELECT 1". Every cell below was run with a binary whose Build ID is recorded next to the result.
b Root cause explained? SSLManager::initDefaultContext(bool server) picks its prefix at SSLManager.cpp:241 and runs once per default context, so the single false default at :345 reached the default client context. With extended verification off, SecureSocketImpl::verifyPeerCertificateImpl returns X509_V_OK at SecureSocketImpl.cpp:467-469 before X509_check_host (:478) or X509_check_ip_asc (:487), and nothing calls SSL_set1_host. The chain was validated, the name never was.
c Fix matches root cause? Yes. The default is corrected where it is read, so no call site is patched and no check is added at a failure site. The ZooKeeperImpl hunk is the same invariant: that carrier supplied no host name to check against, so it verified the resolved IP.
d Test intent preserved / new tests added? 4 new arms: 3 in test_accept_invalid_certificate (mismatch rejected by default, tls-sni-override accepted, extendedVerification=false accepted) and 1 in test_keeper_secure_client. The 6 existing arms of the first suite and the existing arm of the second are untouched and still assert what they did. Four CI sites verify a certificate that does not name the address they dial; three opt out only where peer identity is not what the test is about, and test_ssl_cert_authentication instead sets tls-sni-override to the host it already declares, which strengthens rather than waives its check. No container suite could be executed on this host, since docker networking is unavailable on it, so the new arms were measured locally against those suites' own fixture certificates and the container plumbing is left to CI.
e Both directions demonstrated? Yes, from the same fixture and the same command on both binaries. Client side: mismatch 1 -> Code: 210 ... Unacceptable certificate from <host>; --tls-sni-override 1 -> 1 (so it is a hostname check, not a blanket reject, and the chain is valid); extendedVerification=false 1 -> 1. Secure Keeper: Unacceptable certificate from <resolved IP> -> success, with both arms pinning extendedVerification=true in config so the only variable is the ZooKeeperImpl change.
f Fix is general across code paths? Fixed at the boundary, so all carriers of the default client context are covered at once: pooled HTTPS (s3(), url(), HTTP dictionaries, REST catalogs), the native secure protocol, JWT/OIDC, the Silk socket factory, and the secure Keeper client, which was the one carrier supplying no peer host name and now supplies one. Silk::streamSocketFactory also supplies none, but it has no callers in the tree, so no connection reaches it. Server-side readers (TLSHandler, PostgreSQLHandler) build SERVER_USE contexts from their own prefixes, and Keeper raft uses NuRaft/asio and never reads extendedVerification.
g Fix generalizes across inputs (params/datatypes/wrappers)? Type wrappers do not apply; the input axis is the host string and the verification mode. Measured: IPv4, bracketed IPv6, DNS name, service-name port and local-socket path for the host/port split, each against Poco's own split; loopback vs non-loopback and relaxed vs strict on both the client and the server side; certificates with a dNSName SAN and without one (the CN-fallback path).
h Backward compatible? (maintainer-approved exception only) Deliberately breaking, category Backward Incompatible Change. Requested by the issue author, @ alexey-milovidov, on #35504 (2025-02-24), who raised it for clickhouse-client and judged the compatibility risk acceptable there; on #75351 @ santrancisco wrote that the default "could be enabled by default in the near future". The escape hatch openSSL.client.extendedVerification=false already existed and is measured working, --tls-sni-override is measured working, and the loopback exemption keeps single-host setups working. SettingsChangesHistory.cpp tracks query settings only and holds no server settings, so no entry is possible; the ServerSettings.cpp default moves with the literal so system.server_settings and the generated reference page do not contradict the effective behaviour. No format or serialisation change.
i Invariants and contracts preserved? The invariant is that an outbound TLS connection verifies the certificate against the host that was asked for. setPeerHostName is called before connect(), so before the handshake reads it, and only when a name exists; the empty case falls back to exactly the previous behaviour. The SecureStreamSocket is assigned into the existing StreamSocket member as before, and Socket::operator= shares the SocketImpl pointer, so the name survives the assignment. No lock, allocation or error path is added, and the helper is pure and total. The server default stays false, which is what keeps ssl_certificate authentication working: measured, a bare true rejects a CN=client1 certificate with Unacceptable certificate from <client IP>.

Session id: cron:clickhouse-impl-slot-4:20260827-110200

@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3c90c93]

Summary: ✅


AI Review

Summary

This PR enables hostname verification by default for the default outbound TLS client context, carries the configured host name into secure Keeper connections so verification checks the configured host instead of the resolved address, and updates the affected tests and docs. I did not find a correctness, safety, or compatibility issue in the current diff after tracing the default client-context callers, the Keeper path, the new regression coverage, and the current green CI reports.

Final Verdict

✅ No blocking findings.

LLVM Coverage Report

Measured on commit 3c90c93.

Metric Baseline Current Δ
Lines 88.40% 88.40% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 80.70% 80.70% +0.00%

Changed lines: Changed C/C++ lines covered: 16/19 (84.21%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Aug 27, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @santrancisco @michael-anastasakis @Michicosun, could you review this? It turns hostname verification on for the default client context only (SSLManager::initDefaultContext reads one extendedVerification literal for both prefixes, so a bare true also breaks ssl_certificate authentication), and it makes the secure Keeper client carry its configured host name instead of verifying the resolved address. It is a deliberate backward incompatible change, with the compatibility surface and the opt-out in the description.

@clickhouse-gh

clickhouse-gh Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3c90c934a with master 24e639f8d (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 712.33 MiB 709.27 MiB -3.06 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

11 translation units recompiled, 39 s compile time in total, 11 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 3c90c93

CI is fully finished at this head and no check failed, so no ledger row is owed.

Evidence: 175 unique check runs on the PR workflow run (33079542276), 0 incomplete, 0 failing
conclusions; Config Workflow, Style check and Finish Workflow all success. The praktika report
for this head has 176 nodes, all in {OK, SKIPPED}, root OK, 0 DROPPED, and the 25 SKIPPED are digest
skips with every affected job present and run. CIDB returns 305,072 rows at this commit and 0 of them
are FAIL or ERROR, so the green reading is a measurement and not an empty query.

Session id: cron:our-pr-ci-monitor:20260827-190000

@clickhouse-gh

clickhouse-gh Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 40 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 155a45ac-f9b1-470b-b44e-704773221fc6
  • MIRAI run: cf618dfb-c6c7-4cec-83a2-37b48a007ca6
  • PR check IDs:
    • clickbench_122297_1788983964
    • clickbench_122401_1788983976
    • clickbench_122504_1788984007
    • tpch_adapted_1_official_122524_1788984008
    • tpch_adapted_1_official_122539_1788984009
    • tpch_adapted_1_official_122835_1788984027

@clickhouse-gh clickhouse-gh Bot added the comp-authentication Identity verification: users, credentials, auth methods, external auth providers. label Sep 4, 2026
@alexey-milovidov alexey-milovidov self-assigned this Sep 20, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 20, 2026
Merged via the queue into ClickHouse:master with commit c67f0b1 Sep 20, 2026
188 of 189 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 20, 2026
@rschu1ze rschu1ze added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 20, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 20, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 20, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 20, 2026
Backport #116724 to 26.9: Verify the server certificate hostname on outbound TLS connections
clickhouse-gh Bot added a commit that referenced this pull request Sep 20, 2026
Backport #116724 to 26.7: Verify the server certificate hostname on outbound TLS connections
PedroTadim added a commit that referenced this pull request Sep 20, 2026
Backport #116724 to 26.8: Verify the server certificate hostname on outbound TLS connections
PedroTadim added a commit that referenced this pull request Sep 20, 2026
Resolved the single conflict, in `src/Common/ZooKeeper/ZooKeeperImpl.cpp`. Master adds the
new `peerHostName` helper to an anonymous namespace that also holds `triggerWatchCallback`,
a master-only function 26.3 does not have, so taking master's side wholesale would have
imported it along with `ZooKeeperWatchCallbackDurationMicroseconds` and
`ZooKeeperWatchCallbackErrors`, which the branch does not declare. Only `peerHostName` and
its `setPeerHostName` call site were taken; the rest of the file is the branch's.

Everything else applied cleanly. The docs row landed in 26.3's
`docs/en/operations/server-configuration-parameters/_server_settings_outside_source.md`,
which master has since renamed to an `.mdx` under `docs/reference`.

Checked the branch's own test set for the flipped `openSSL.client.extendedVerification`
default: the only integration configs that still verify and carry no opt-out are
`test_config_xml_main`, `test_config_xml_yaml_mix`, `test_https_replication`,
`test_ssl_cert_authentication` and `test_tlsv1_3`, and each one's client section is
identical to master's, so none needs a 26.3-specific adjustment. The prerequisites the new
tests rely on are present on the branch: `tls-sni-override` with `setPeerHostName` in
`Connection.cpp`, `SSL_HOST` in `test_ssl_cert_authentication`, the CA-signed `CN=client`
certificate with no SAN in `test_accept_invalid_certificate/certs`, and
`<host>node1</host>` in `test_keeper_secure_client/configs/use_secure_keeper.xml`, which
the regenerated certificate now names in its `subjectAltName`.

Original pull-request #116724
Cherry-pick pull-request #121185

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
robot-clickhouse added a commit that referenced this pull request Sep 20, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 20, 2026
PedroTadim added a commit that referenced this pull request Sep 21, 2026
Backport #116724 to 26.3: Verify the server certificate hostname on outbound TLS connections
strtgbb pushed a commit to Altinity/ClickHouse that referenced this pull request Sep 21, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 25, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 26, 2026
`test_tls13_client_cipher_suites` connects between instances with
`remoteSecure('<instance>:9440', ...)`, while the module's `server-cert.pem`
names only `integration-tests.clickhouse.com`. Since ClickHouse#116724 the default
client context checks that the certificate names the host being dialed, so
with that change merged every connection in the arm fails before the cipher
suites matter:

    Certificate validation error: Unacceptable certificate from
    node_with_cipher_suites: application verification failure

The arm asserts which TLS 1.3 suites a client offers, not the identity of the
peer, so the module's `openSSL.client` section sets `extendedVerification` to
`false`, as ClickHouse#116724 did for `test_bind_host` and `test_acme_tls`. The chain is
still verified against the test CA.

Measured with the CI `amd_asan_ubsan` binary of this head (merge commit
5e6ee40): the arm fails with the error above without the change and
passes with it, 10 out of 10, and the whole module passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
valerypetrov pushed a commit to valerypetrov/ClickHouse that referenced this pull request Oct 13, 2026
…ls-verify-outbound-hostname"

This reverts commit c67f0b1, reversing
changes made to cbc807e.
clickhouse-gh Bot pushed a commit that referenced this pull request Oct 14, 2026
Edited by the nightly changelog CI job following .claude/skills/edit-changelog/SKILL.md.

Changelog-revert: 125458 125455 Revert "Revert "Iceberg variant type""
Changelog-revert: 125463 110114 Revert "Push filters below WindowStep on PARTITION BY columns"
Changelog-revert: 125569 116724 Revert "Verify the server certificate hostname on outbound TLS connections"
Changelog-revert: 125652 123834 Revert "Look up both signed zeros in a bloom_filter index"
Changelog-deleted-entry: 116724 [Backward Incompatible Change] [section] * Outbound TLS connections now verify that the server certificate names the host that was connected to. This affects `clickhouse-client --secure`, `remoteSecure`, `Distributed` over the secure native protocol, secure `Keeper` connections, and HTTPS clients such as `s3`, `url`, HTTP dictionaries, and JWT token endpoints. Connecting to an endpoint whose certificate does not name it, for example an IP address with no matching SAN, an S3-compatible gateway fronted by a different name, or an internal CA with missing SANs, now fails with `Unacceptable certificate`. Set `openSSL.client.extendedVerification` to `false` to restore the previous behavior, or pass `--tls-sni-override` to name the host the certificate was issued for. Loopback addresses stay exempt unless `verificationMode` is `strict`, and the default for `openSSL.server.extendedVerification` is unchanged. [#116724](#116724) ([Groene AI](https://github.com/groeneai)).
Changelog-deleted-entry: 123834 [Bug Fix (user-visible misbehavior in an official stable release)] [section] * Fixed a `bloom_filter` index on a float column skipping rows with the other signed zero, for example `-0.0` for `WHERE f = 0`. It affected `equals`, `has`, `hasAny`, `hasAll`, `mapContainsKey`, `mapContainsValue`, and map element comparisons, including `m[k] IN (...)`. [#123834](#123834) ([Ashish Kumar Choubey](https://github.com/aschoube)).
@nihalzp

nihalzp commented Nov 18, 2026

Copy link
Copy Markdown
Member

@groeneai This change makes every outbound TLS handshake do a DNS lookup, and it slowed down the cold queries of the ClickHouse (web) entry of ClickBench. Let's fix it.

On c8g.metal-48xl and c7a.metal-48xl, six cold queries (Q20, Q27, Q28, Q32, Q33, Q34) take 5.2 to 5.6 s instead of 0.6 to 1.4 s. They flip on the first daily run after each change of the default (result files):

Change Merged Cold Q32 on c8g.metal-48xl
This PR 2026-09-20 1.48 s on 2026-09-20, 5.50 s on 2026-09-21
#125569 (revert) 2026-10-13 5.53 s on 2026-10-13, 0.70 s on 2026-10-14
#126138 (landed again) 2026-10-22 1.44 s on 2026-10-22, 5.42 s on 2026-10-23

@groeneai

Copy link
Copy Markdown
Collaborator Author

Acknowledged. I'm investigating the cold-query slowdown of ClickHouse (web) caused by the hostname verification change; I'll follow up here with a PR (or my findings) shortly.

@groeneai

Copy link
Copy Markdown
Collaborator Author

I opened #132627 to fix it. The hostname check evaluated the loopback exemption (isLocalHost, an uncached getaddrinfo on the host name) before X509_check_host. It now runs only when the certificate does not name the host, so verification stays on and its result is unchanged for every certificate.

Measured locally: cold ClickBench Q37 against a web endpoint (65 TLS handshakes) did 66 DNS queries on master and 1 with the fix. My box uses a local caching resolver, so I could not reproduce the 5 s itself.

qoega pushed a commit to qoega/ClickHouse that referenced this pull request Nov 19, 2026
Since `openSSL.client.extendedVerification` is on by default (ClickHouse#116724,
relanded by ClickHouse#126138), `SecureSocketImpl::verifyPeerCertificateImpl`
evaluated the loopback exemption `isLocalHost(hostName)` before
`X509_check_host`. `isLocalHost` builds `SocketAddress(hostName, 0)`,
which for a host name calls an uncached `getaddrinfo`, so every outbound
TLS handshake did one DNS lookup that the TCP connect (served by the
cached `DNSResolver`) never needed. A cold query over a `web` or `s3`
disk opens many new HTTPS connections, so the lookups add up.

The exemption only matters when the certificate does not name the host;
check it only then. The result is the same for every certificate: the
same default, the same loopback exemption, and `strict` mode still never
exempts.

Reported in ClickHouse#116724 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-authentication Identity verification: users, credentials, auth methods, external auth providers. groeneai-origin-oranjeai PR origin: delegated from the OranjeAI sibling fleet pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backward-incompatible Pull request with backwards incompatible changes pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clickhouse-client does not check domain name of the server's SSL certificate

7 participants