Post-quantum TLS on Linux: Nginx, Apache and HAProxy
Hybrid key exchange with X25519MLKEM768 protects traffic against being collected now and decrypted later with a quantum computer. You enable it in the web server configuration, and the certificate does not need to be replaced for it.
Nginx, Apache and HAProxy must run with OpenSSL 3.5 or later. Nginx and HAProxy call the groups curves.
What your distribution can do
Check the OpenSSL version first. The table covers Nginx, Apache and HAProxy from the distribution packages:
openssl version| Distribution | OpenSSL | X25519MLKEM768 | What you do |
|---|---|---|---|
| Debian 12 | 3.0 Source: Debian: openssl package versions (opens in a new tab) | No | Upgrade to Debian 13. |
| Debian 13 | 3.5 Source: Debian: openssl package versions (opens in a new tab) | Yes | Set the groups in the web server. |
| Ubuntu 22.04 LTS | 3.0 Source: Ubuntu: openssl package versions (opens in a new tab) | No | Upgrade to Ubuntu 26.04 LTS. |
| Ubuntu 24.04 LTS | 3.0 Source: Ubuntu: openssl package versions (opens in a new tab) | No | Upgrade to Ubuntu 26.04 LTS. |
| Ubuntu 26.04 LTS | 3.5 Source: Ubuntu: openssl package versions (opens in a new tab) | Yes | Set the groups in the web server. |
| RHEL 9 | 3.5 from RHEL 9.7 Source: Red Hat: RHEL 9.7 release notes (opens in a new tab) | Yes, from 9.7 | Update to 9.7 or later and set the groups in the web server. |
| RHEL 10 | 3.5 from RHEL 10.1 Source: Red Hat: Interoperability of RHEL 10 post-quantum cryptography (opens in a new tab) | Yes, from 10.1 | Update to 10.1 or later and set the groups in the web server. In FIPS mode only SecP256r1MLKEM768 and SecP384r1MLKEM1024 work. |
How to enable it
The lines allow TLS 1.3 and TLS 1.2 with ECDHE and AEAD. The groups are in two sets separated by /: the three hybrids first, then P-384 and P-521 as fallback. The server picks a hybrid group whenever the client supports one of them.
Test the clients first
A client that only supports X25519 or P-256, TLS 1.0 or 1.1, or CBC ciphers cannot connect with these lines. Test the applications and clients that use the server.
- Save a copy of the configuration file. This is Nginx; for Apache and HAProxy it is their configuration file:
sudo cp -an /etc/nginx/nginx.conf /etc/nginx/nginx.conf.before-pqc - Add the lines for your server as shown below. If the lines are already there, change them instead of adding new ones.
- Test the configuration and reload with the command under your server.
- Test the server from outside with testssl.sh.
Nginx
Put the lines in the http block. They apply to every server block without settings of its own:
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
# Hybrid groups first, then P-384 and P-521
ssl_ecdh_curve X25519MLKEM768:SecP256r1MLKEM768:SecP384r1MLKEM1024/secp384r1:secp521r1;sudo nginx -t && sudo systemctl reload nginxApache
Put the lines in the server configuration or in <VirtualHost>:
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
# Hybrid groups first, then P-384 and P-521
SSLOpenSSLConfCmd Groups X25519MLKEM768:SecP256r1MLKEM768:SecP384r1MLKEM1024/secp384r1:secp521r1sudo apachectl configtest && sudo apachectl gracefulHAProxy
Put the lines in the global section. They apply to every bind line without settings of its own:
global
ssl-default-bind-options ssl-min-ver TLSv1.2
ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
# Hybrid groups first, then P-384 and P-521
ssl-default-bind-curves X25519MLKEM768:SecP256r1MLKEM768:SecP384r1MLKEM1024/secp384r1:secp521r1sudo haproxy -c -f /etc/haproxy/haproxy.cfg && sudo systemctl reload haproxyTraefik
Traefik uses Go instead of OpenSSL. Built with Go 1.24 or later, Traefik uses X25519MLKEM768 when curvePreferences is not set; traefik version shows the Go version. If you have a list in the dynamic configuration, X25519MLKEM768 must be in it. That requires Traefik 3.5 or later:
tls:
options:
default:
minVersion: VersionTLS12
cipherSuites:
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
curvePreferences:
- X25519MLKEM768
- CurveP384
- CurveP521Test with testssl.sh
Test from outside with testssl.sh (opens in a new tab). Download the latest version, at least 3.2.4, from the releases on GitHub (opens in a new tab) and unpack it. testssl.sh runs in Bash on Linux, macOS and WSL.
Run the command from the unpacked directory and replace www.example.com with the hostname your clients use:
./testssl.sh --fs www.example.com--fs limits the test to the key exchange. The hybrid group is listed under KEMs offered. This is the line for www.fairssl.dk:
KEMs offered X25519MLKEM768 Look for the hybrid group you enabled. None means the test found no hybrid group. With the lines for Nginx, Apache and HAProxy, Elliptic curves offered: shows secp384r1 and secp521r1.
Undo
Put the copy from step 1 back, test the configuration and reload:
sudo cp -a /etc/nginx/nginx.conf.before-pqc /etc/nginx/nginx.conf
sudo nginx -t && sudo systemctl reload nginxKey type in the ACME client
The key type of the certificate is chosen in the ACME client on each server. Based on what we know today, we recommend RSA 3072-bit keys, or ECC 384 if you need faster performance.
How to set the key type is described in the lego guide for Linux, the lego guide for macOS and the simple-acme guide for Windows.
See also
- Mozilla SSL Configuration Generator: the whole TLS configuration for your server.
- Install a certificate in Nginx, Apache or HAProxy.
- Post-quantum TLS on Windows Server
- News: NSA’s PQC news without the hype: what to change on servers and certificates