← Back to section · Tutorials & Labs
Deployment in Practice: Enabling Hybrid Post-Quantum TLS on nginx
Two real paths: native hybrid groups in OpenSSL 3.5, or the oqs-provider on older versions. Prerequisites, configuration steps, negotiation verification, and rollback.
When post-quantum algorithms are deployed into real systems, the first stop is usually the web front door. The goal of this article is concrete: make an nginx server prefer the hybrid key exchange group X25519MLKEM768 (X25519 + ML-KEM-768) in TLS 1.3 handshakes, while keeping classical groups as a fallback for older clients. First, the boundary: this migrates key exchange only. The server certificate remains classical ECDSA or RSA — public CAs have no path to issue ML-DSA certificates yet, and certificate migration is a separate job. Do not do the two together.
Prerequisites: Look at OpenSSL, Not nginx
nginx’s TLS capability comes from the OpenSSL it was built against, so the first step is always to check versions:
nginx -V 2>&1 | tr ' ' '\n' | grep -i ssl
openssl version
openssl list -groups 2>/dev/null | grep -i mlkem
The watershed is OpenSSL 3.5 (released April 2025): it ships ML-KEM, ML-DSA, and SLH-DSA natively, and its default TLS 1.3 group list already includes X25519MLKEM768. If your distribution provides 3.5 or later (or the nginx official packages link against it), take the native path — the configuration is cleanest. If you can only get 3.0–3.4, the only option is the Open Quantum Safe oqs-provider plugged in as a provider. It must be said plainly: oqs-provider is officially positioned for research and interoperability testing, its algorithm names (such as x25519_kyber768) do not fully match the final standards, and production environments should push to upgrade OpenSSL rather than stay on the provider long-term. The two paths use different group names; before configuring, check openssl list -groups and trust your machine’s actual output.
Steps: Declare Group Priority and Reload
On the native path, state the curve group order explicitly in the http or server block of nginx:
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1;
ssl_prefer_server_ciphers on;
Line one restricts protocol versions (hybrid groups exist only in TLS 1.3). Line two is the core: the hybrid group first, classical groups after; the server picks the hybrid group first, and older clients automatically land on X25519. Line three makes the server’s order authoritative. On the oqs-provider path, first activate the provider in openssl.cnf, then substitute the group names it exposes; the rest is the same. After editing, run nginx -t to validate syntax, then nginx -s reload for a graceful reload — do not restart and drop connections. If your distribution nginx links the system OpenSSL, note that some distributions delegate group policy to a system-wide crypto policy (such as crypto-policies on the RHEL family); in that case ssl_ecdh_curve may be overridden, and the verification step below will expose it.
For Apache users, the equivalent is mod_ssl: from 2.4.x onward, SSLOpenSSLConfCmd Curves X25519MLKEM768:X25519 achieves the same effect, with the same prerequisite of linking OpenSSL 3.5.
Verification: Confirm Negotiation Actually Happens, Twice
Correct configuration does not mean negotiation happens; you must measure it. Locally, connect with the OpenSSL 3.5 s_client, pinning the group:
openssl s_client -connect your.host:443 -groups X25519MLKEM768 -brief
The output should show the negotiated group as X25519MLKEM768. Then connect again without -groups and confirm the default connection also lands on the hybrid group first. Second path: visit with a real browser and check the security panel in developer tools (Chrome shows the key exchange group used), confirming the production traffic view matches. Also run a downgrade test: connect with a legacy client that only supports classical groups (or s_client with -groups X25519) and confirm it lands cleanly on a classical group instead of failing the handshake — during rollout, that fallback is your safety net.
Scope: Which Sites Change First, Which Can Wait
Not every nginx instance needs to change at the same time. Prioritize on two axes: confidentiality lifetime of the traffic, and traffic volume. Sites serving login, payment, medical, or government data — traffic whose recorded value stays high for years — go first. Purely public static content sites lose nothing extra if recorded traffic is decrypted later, and can wait. East-west traffic between internal services is often forgotten, yet it carries database replication, admin interfaces, and key distribution; if an attacker can capture packets inside the network, harvest-now-decrypt-later applies equally, so plan it in the same batch as the public front door. A final category is edge nodes that only reverse-proxy: they terminate TLS, so they are the real negotiation point and rank the same as the origin — do not be misled by “it’s just a proxy.” After ordering, proceed in batches; the per-batch verification and observation method is covered in this section’s canary rollout article, and this article’s per-machine steps are reused as-is in each batch.
Performance and Size: Two Bills to Measure Before Launch
Hybrid key exchange is not free; measure two bills before going live. The byte bill: an ML-KEM-768 encapsulation key is 1,184 bytes and the ciphertext 1,088 bytes, so one hybrid handshake has the client send roughly 1.2 KB more and the server return roughly 1.1 KB more. That sounds small, but it pushes the TLS ClientHello across a common TCP initial congestion window boundary, which can add a round trip on high-latency links; the server’s first flight (ServerHello plus certificate chain) also needs re-checking that it still fits in one window. The compute bill: ML-KEM key generation and decapsulation are very fast and usually not the bottleneck; what matters is the change in new-connections-per-second under high handshake concurrency — sites with a high share of full handshakes (short-connection APIs, frequently reconnecting clients) feel it most, while sites with mostly long connections and session resumption barely notice. The measurement is direct: in a load-test environment, run the same traffic model against classical and hybrid groups, record handshakes per second and CPU usage, and the difference is your capacity discount factor — write it into capacity planning rather than discovering it at peak. Session resumption amortizes this cost, so also confirm the resumption rate does not drop abnormally after the change. Finally, older monitoring probes that only recognize classical group names may flag the hybrid group as unknown and false-alarm; update the group name dictionary in your monitoring rules at the same time.
Rollback and Common Pitfalls
Rollback is just reverting ssl_ecdh_curve to the original classical group list and reloading; certificates and keys never change, so rollback is second-level and stateless. Three common pitfalls: first, the OpenSSL that nginx links may not be the same openssl on your command line (common with multiple versions installed) — trust the build information in nginx -V. Second, group names differ by path: native is X25519MLKEM768, oqs-provider uses names like x25519_kyber768; a typo silently falls back to classical groups, and only the verification step catches it. Third, when an intermediary (CDN, WAF, load balancer) terminates TLS, negotiation really happens at that layer and changing the origin accomplishes nothing — draw clearly where TLS terminates before deciding what to change. After this article, your web front door is closed against harvest-now-decrypt-later attacks; the next step is the SSH channel (see the OpenSSH article in this section).
Tags: nginxTLSHybrid Key ExchangeDeployment