Skip to content

Detect and use TLS port and host configurations#16

Merged
theory merged 1 commit into
mainfrom
tls
Oct 10, 2025
Merged

Detect and use TLS port and host configurations#16
theory merged 1 commit into
mainfrom
tls

Conversation

@theory
Copy link
Copy Markdown
Collaborator

@theory theory commented Oct 10, 2025

Inspect the host name and port to determine whether to make a TLS connection to ClickHouse. The new internal function ch_is_cloud_host() returns a value other than 0 if the host name argument is a ClickHouse cloud host, matching any of the ClickHouse cloud environment host names.

For binary connections, set the port to the ClickHouse secure port if ch_is_cloud_host() returns true for the host name and enable TLS if the port, whether explicitly specified for the connection or set by matching the host name, is the ClickHouse secure port.

For HTTP connections, set the port to the ClickHouse TLS HTTP port if ch_is_cloud_host() returns true for the host name. Then set the URL scheme to "https" if the port, whether explicitly specified for the connection or set by matching the host name, is the ClickHouse TLS secure port or the standard HTTPS port.

Tested both patterns against a .clickhouse.cloud host name and used it to successfully import a schema.

In passing, remove a debugging printf statement from .github/ubuntu/clickhouse.sh and a duplicate library argument to SHLIB_LINK in the Makefile.

Inspect the host name and port to determine whether to make a TLS
connection to ClickHouse. The new internal function `ch_is_cloud_host()`
returns a value other than `0` if the host name argument is a ClickHouse
cloud host, matching any of the ClickHouse cloud environment host names.

For binary connections, set the port to the ClickHouse secure port if
`ch_is_cloud_host()` returns true for the host name and enable TLS if
the port, whether explicitly specified for the connection or set by
matching the host name, is the ClickHouse secure port.

For HTTP connections, set the port to the ClickHouse TLS HTTP port if
`ch_is_cloud_host()` returns true for the host name. Then set the URL
scheme to "https" if the port, whether explicitly specified for the
connection or set by matching the host name, is the ClickHouse TLS
secure port or the standard HTTPS port.

Tested both patterns against a `.clickhouse.cloud` host name and used it
to successfully import a schema.

In passing, remove a debugging `printf` statement from
`.github/ubuntu/clickhouse.sh` and a duplicate library argument to
`SHLIB_LINK` in the `Makefile`.
@theory theory requested a review from serprex October 10, 2025 18:31
@theory theory self-assigned this Oct 10, 2025
@theory theory merged commit 64be748 into main Oct 10, 2025
30 checks passed
@theory theory deleted the tls branch October 10, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants