Skip to main content
Yes. Forward secrecy means that the keys encrypting a connection cannot be recovered later, not even by someone who obtains the long-term private key of the server. Someone who records your encrypted traffic today and steals the server key next year still cannot read what they recorded. In ClickHouse:
  • Every TLS 1.3 connection is forward secret. This is what ClickHouse negotiates by default, as a server and as a client, and no setting of ClickHouse can turn the property off.
  • Every SSH session is forward secret.
  • TLS 1.2 connections are forward secret with current clients, and one line of configuration makes it unconditional.
  • Session keys never leave the process. They are not written to disk, and the key logging facility of OpenSSL is compiled out.
The rest of this page explains the idea, tells what happened where forward secrecy was missing, and then lists the guarantees in detail, with the commands to check them.

The idea

There are two ways for a client and a server to agree on the keys of an encrypted session. In the first one, the client picks a random secret, encrypts it with the public key from the certificate of the server, and sends it over. Only the server can decrypt it, and both sides derive the session keys from it. This is the RSA key exchange, and for many years it protected most of the encrypted traffic on the Internet. It is simple and fast, and it has one property that is easy to overlook: the same private key unlocks every session the server has ever had. Whoever records the traffic and later obtains that one key, whether by theft, by a software bug, or by a court order, can decrypt all of it, back to the day the key was created. In the second one, both sides generate a fresh key pair for this connection only, exchange the public halves, and compute a shared secret with the Diffie-Hellman algorithm. When the handshake is complete, the temporary private keys are destroyed. The long-term key of the server has a single remaining job: it signs the handshake, to prove that the client is talking to the right server. It does not encrypt anything. After the connection ends, nobody can derive its keys again: not the server, not the client, and not an attacker who has the private key of the certificate and a complete recording of the traffic. The second design is forward secret. The secrecy of a finished conversation does not depend on any secret that still exists.

A short history

The mechanism is as old as public-key cryptography. Whitfield Diffie and Martin Hellman published the key agreement that bears their names in 1976. The name for the property came later: Christoph Günther introduced “perfect forward secrecy” in 1989, and in 1992 Diffie, Paul van Oorschot and Michael Wiener gave the definition that is still quoted:
An authenticated key exchange protocol provides perfect forward secrecy if disclosure of long-term secret keying material does not compromise the secrecy of the exchanged keys from earlier runs.
The word “perfect” is historical and is often dropped today. SSL 3.0 offered ephemeral Diffie-Hellman cipher suites in 1996, but almost nobody used them. The extra computation was expensive for the servers of the time, and the risk seemed theoretical: who records encrypted traffic for years in the hope of getting a key? It took fifteen years and several incidents to answer that question:
  • 2011. Google enabled forward secrecy for Gmail and its other HTTPS services on 2011-11-22, making the case that traffic recorded today should not become readable when a key is compromised in the future.
  • 2013. The documents disclosed by Edward Snowden showed that recording encrypted traffic on a large scale was not a hypothesis: the rules of the NSA allowed the agency to store any encrypted communication it collected. In October of that year, SSL Pulse found that 54% of the most popular HTTPS sites did not support forward secrecy with any browser. Twitter enabled it in November, and others followed.
  • 2018. TLS 1.3 closed the question in the protocol itself. RFC 8446 lists it among the major differences from TLS 1.2: “Static RSA and Diffie-Hellman cipher suites have been removed; all public-key based key exchange mechanisms now provide forward secrecy.” In the same year, the share of sites without forward secrecy in SSL Pulse was 4.5%, and in 2025, 0.2%.
The removal was deliberate, and it was contested. While TLS 1.3 was being designed, an association of financial institutions asked the IETF to hold the standard back, because their monitoring tools decrypted internal traffic with the private keys of the servers. The IETF did not yield. A variant of the protocol with a long-lived key was later published by another standards body, ETSI, under the name ETS, and it received a vulnerability identifier for exactly this property: CVE-2019-9191, “does not provide per-session forward secrecy”. ClickHouse does not implement it.

When it was missing

One key for a month of messages: Enigma, 1941

Long before the term existed, the German Navy distributed the settings of its Enigma machines as printed key lists that covered a month. In 1941 the Royal Navy captured two weather ships that carried such lists, the München on 1941-05-07 and the Lauenburg on 1941-06-28. With the captured keys, Bletchley Park read the naval traffic of June and July 1941 without delay, which it had not been able to do before. A long-lived secret that unlocks everything sent under it is the exact opposite of forward secrecy.

Recorded in the 1940s, read until 1980: Venona

On 1943-02-01 the US Army started a project to read encrypted Soviet diplomatic telegrams. The cipher was a one-time pad, unbreakable when used correctly, but the manufacturer of the pads had duplicated some of the pages. That flaw was enough to let the analysts work through the archive, slowly, for decades. The project ran until 1980-10-01, and in the end it had read, at least in part, about 3,000 telegrams sent between 1940 and 1948. Venona is the classic proof that an adversary with patience stores ciphertext, and that “nobody can read it now” is not the same as “nobody will ever read it”.

One court order for 400,000 mailboxes: Lavabit, 2013

Lavabit was an email provider with more than 400,000 users. In the summer of 2013 the US government, in an investigation of one of them, widely reported to be Edward Snowden, obtained a court order for the private TLS key of the service. Its founder, Ladar Levison, first delivered the key as an eleven-page printout in 4-point type. The court imposed a sanction of 5,000 dollars a day until he provided it in a usable form, which he did two days later, and then he shut the service down. The key was not the key to one mailbox. It protected the connections of every user. And it reached into the past: as Moxie Marlinspike pointed out a few months later, “since Lavabit wasn’t preferring PFS SSL cipher suites, the government would have been able to go back and decrypt previous traffic with Lavabit’s SSL key.”

The bug that leaked private keys: Heartbleed, 2014

On 2014-04-07 a bug in OpenSSL became public that let anyone on the Internet read fragments of the memory of a vulnerable server. Four days later, in a challenge set up by Cloudflare, two people independently extracted the private key of a server this way. For servers that used the RSA key exchange, this was a disaster in two directions: the stolen key allowed impersonating the server in the future, and decrypting everything that had been recorded in the past. Replacing the certificate helped only with the first. In the words of the announcement, it “will still leave any traffic intercepted by the attacker in the past still vulnerable to decryption”. The same page named the remedy:
Use of Perfect Forward Secrecy (PFS), which is unfortunately rare but powerful, should protect past communications from retrospective decryption.
Servers that used forward secret key exchanges had to replace their certificates too, but their past traffic stayed sealed. Heartbleed turned forward secrecy from a recommendation into a requirement.

Keys stolen in bulk: the SIM card heist, 2015

In February 2015 The Intercept reported, on the basis of leaked documents, that the British agency GCHQ, with the support of the NSA, had broken into the network of Gemalto, the largest manufacturer of SIM cards, to copy the keys that are stored on the cards and shared with the mobile operators. Gemalto said that an intrusion had probably happened, but disputed that keys had been stolen on a massive scale. The encryption between a phone and the mobile network is derived from that one long-lived key, and the report spells out what follows:
Because cellphone communications do not utilize PFS, if an intelligence agency has been ‘passively’ intercepting someone’s communications for a year and later acquires the permanent encryption key, it can go back and decrypt all of those communications.

Forward secrecy with a shortcut: Logjam, 2015

Ephemeral keys alone are not enough if everyone performs the exchange in the same weak group. The Logjam paper, titled “Imperfect Forward Secrecy”, showed in May 2015 that servers all over the Internet shared a handful of 1024-bit Diffie-Hellman primes, and that an attacker with the resources of a nation state could do the expensive part of the computation once per prime and then break individual connections cheaply. Breaking the most common prime would allow passive eavesdropping on 18% of the top million HTTPS sites, and breaking a second one, on 66% of VPN servers and 26% of SSH servers. Forward secrecy needs strong parameters as much as it needs temporary keys, which is why modern protocols use elliptic curves and standardized groups of at least 2048 bits.

Other places where it is missing

  • Encrypted email with PGP or S/MIME is not forward secret: a message is encrypted to the long-term key of the recipient. Instant messaging took the other road: Off-the-Record Messaging made forward secrecy a design goal in 2004, and the Signal protocol continued it.
  • Wi-Fi with a shared password (WPA2-Personal) is not forward secret either: everyone who knows the password and has recorded the handshake of a device can decrypt its traffic. WPA3 replaced the handshake with a forward secret one.
  • The RSA key exchange kept breaking. ROBOT, in December 2017, revived an attack from 1998 on RSA encryption in TLS, and it worked against the servers of Facebook, among others. For a server that supported only the RSA key exchange, the authors wrote, “an attacker can passively record traffic and later decrypt it”.
  • Debugging tools show it plainly. Wireshark can decrypt a recorded TLS session if you give it the private key of the server, but only if the session did not use an ephemeral key exchange, and never with TLS 1.3.

What ClickHouse guarantees

TLS 1.3: always

ClickHouse negotiates TLS 1.3 with every peer that supports it. In TLS 1.3 there is no key exchange without ephemeral keys, so the property does not depend on the configuration, on the cipher suite, or on the type of the certificate:
  • Every key exchange is ephemeral. By default it is the hybrid X25519MLKEM768, or X25519 or a NIST curve if the client does not support the hybrid.
  • The private key of the certificate only signs the handshake. Stealing it allows impersonating the server until the certificate is replaced. It does not allow decrypting anything.
  • Resumed sessions run a new key exchange. TLS 1.3 has a mode that resumes a session without one. ClickHouse does not offer it as a client and does not use it as a server, even if the client asks for it.
  • Early data (0-RTT) is disabled. It is the part of TLS 1.3 that is not forward secret, and ClickHouse does not accept it.
No setting of ClickHouse changes any of this. The only way around it is deliberate and outside of the ClickHouse configuration: an OpenSSL configuration file, passed in the OPENSSL_CONF environment variable, that enables resumption without a key exchange with Options = AllowNoDHEKEX,PreferNoDHEKEX. Do not do it. The hybrid key exchange extends the guarantee into the future. A classical forward secret exchange can still be broken by a quantum computer, from a recording, without any key being stolen. X25519MLKEM768 protects against that as well: see Does ClickHouse use post-quantum cryptography?

All interfaces, both directions

The same holds for every TLS port of the server: the HTTPS interface, the native protocol, the interserver port used by replication, the MySQL and PostgreSQL wire protocols, gRPC, and the client and Raft ports of ClickHouse Keeper. It also holds when ClickHouse is the client: for clickhouse-client, for connections between servers in distributed queries and replication, and for outgoing HTTPS connections to object storage and other external sources.

SSH: always

The SSH interface is forward secret in every session. Every key exchange method that the server offers is ephemeral, and the host key only signs.

Session keys stay in memory

  • Ephemeral keys and session keys exist only in the memory of the process and are discarded with the connection.
  • ClickHouse never writes them to disk or to the logs. The SSLKEYLOGFILE facility of OpenSSL, which other programs honor to export session keys for debugging, is compiled out of ClickHouse: setting the variable has no effect.

TLS 1.2: with current clients

TLS 1.2 is still accepted by default, for compatibility with old clients. TLS 1.0 and TLS 1.1 are refused. In TLS 1.2 the key exchange is a part of the cipher suite. With the default configuration, the server picks the strongest cipher suite that both sides support, and among equally strong ones, a suite with an ephemeral elliptic-curve key exchange (ECDHE). Current TLS libraries, drivers and browsers offer ECDHE with their strongest ciphers, so their connections are forward secret. The server does not accept the finite-field Diffie-Hellman suites, the ones that Logjam attacked. Two details of the older protocol are weaker than TLS 1.3:
  • The RSA key exchange is still possible. If the server has a certificate with an RSA key, and the strongest suite that a client offers uses the RSA key exchange, the connection is established without forward secrecy. This takes a client that offers nothing but the RSA key exchange, or offers ECDHE only with weaker ciphers. As a client, ClickHouse offers ECDHE first, and accepts the RSA key exchange from a server that selects it.
  • Session resumption reuses keys. A TLS 1.2 session can be resumed from the session cache of the server or with a session ticket, without a new key exchange. Both exist only in the memory of the server: the cache, and the key that encrypts the tickets.
Neither applies to TLS 1.3. The choice of the server is the effect of preferServerCiphers, which is set in the default configuration file. Without it, the server follows the order of preference of the client.

Make it unconditional

To guarantee forward secrecy for every connection, whatever the clients offer, accept only TLS 1.3. In the server configuration:
The server part covers the connections that the server accepts, and the client part the connections that it makes. The client part has the same meaning in the configuration of clickhouse-client. The gRPC port does not read this setting, and does not need it: it accepts only forward secret cipher suites. If you have to keep TLS 1.2 for old clients, exclude the RSA key exchange instead. Either of these is enough:
  • Restrict the cipher suites of TLS 1.2 to the ephemeral ones with <cipherList>ECDHE+AESGCM:ECDHE+CHACHA20</cipherList>, in the same place as disableProtocols above.
  • Use a certificate with an ECDSA key. The RSA key exchange needs an RSA key and is impossible without one.

What forward secrecy does not cover

  • Data at rest. Stored data has to remain readable, so its key has to be kept. It is protected by the key itself and by rotating it: an encrypted disk accepts several keys and writes new data with the current one.
  • A compromised endpoint. An attacker who controls the server or the client during a session reads the data in plain text. Forward secrecy protects the past, not the present.
  • Impersonation. A stolen private key still lets an attacker pose as the server in new connections, until the certificate is revoked and replaced.
  • Other hops. If a proxy or a load balancer terminates TLS in front of ClickHouse, the key exchange on that hop is the one configured there.

How to check

Connect with openssl s_client and look at the protocol and the key exchange:
Protocol version: TLSv1.3 is sufficient: the connection is forward secret. With TLS 1.2, the cipher suite tells: names that start with ECDHE are forward secret. To check that the server refuses the RSA key exchange after you have made forward secrecy unconditional, request it explicitly. The handshake must fail: