Encrypt traffic between ClickHouse clients and servers using TLS to protect data in motion.
Unencrypted TCP connections expose query text and result sets to interception. TLS protects customer emails, order totals, and product prices as they move between applications and ClickHouse nodes.
Add a secure port and certificate paths in config.xml
. Restart the server for changes to apply.
<tcp_port_secure>9440</tcp_port_secure>
<openSSL>
<server>
<certificateFile>/etc/clickhouse/server.crt</certificateFile>
<privateKeyFile>/etc/clickhouse/server.key</privateKeyFile>
<dhParamsFile>/etc/clickhouse/dhparam.pem</dhParamsFile>
</server>
</openSSL>
Use OpenSSL or your PKI.For internal clusters, a self-signed root CA is fine. For public endpoints, buy a CA-signed certificate or use Let’s Encrypt.
clickhouse-client
?Pass --secure
or --protocol=https
. Verify the hostname matches the cert’s CN/SAN.
clickhouse-client --host db.prod --port 9440 --secure \
--user alice --password ***
Add ssl=true
(JDBC) or use https://
(HTTP interface).Always require validation in production.
# JDBC
jdbc:clickhouse://db.prod:9440?ssl=true&sslmode=required&user=app&password=pwd
# HTTP
curl -s -G "https://db.prod:8443/" --data-urlencode "query=SELECT 1"
See next section for a consolidated cheat-sheet.
Connect with TLS, then run:
SELECT o.id, o.total_amount, c.email
FROM Orders AS o
JOIN Customers AS c ON o.customer_id = c.id
WHERE o.total_amount > 1000
ORDER BY o.total_amount DESC;
Rotate certificates regularly, disable weak ciphers, and monitor the secure port separately.Enforce TLS on every client by default.
Missing secure port: Enabling TLS without <tcp_port_secure>
keeps clients on plain TCP. Always expose 9440 (or your chosen port).
Ignoring certificate validation: Using sslmode=none
negates security. Require full validation in production.
CPU overhead is minimal; disk or network speed is usually the bottleneck. Benchmarks show <3% impact for typical analytics workloads.
Yes.Add <verificationMode>strict</verificationMode>
and supply client certificates during connection.
Run openssl s_client -connect db.prod:9440
to inspect the certificate chain and cipher suite.
.
On modern CPUs the overhead is tiny—usually under 3%. The network round-trip or disk scan dominates latency.
You can if the Subject Alternative Name covers all hostnames, but unique certs per node simplify revocation.
Not required, but enabling client certificate validation adds an extra authentication layer, useful for internal microservices.