Post-quantum TLS with NGINX Gateway Fabric: checking it’s on and keeping it on

—

by

in , , ,
The NGINX Gateway Fabric logo is on the top left of the image, with the blog post title Post-quatum TLS with NGINX Gateway Fabric: checking it's on and keeping it on". To the right is an illustration of a male-presenting person with brown skin standing next to a screen or whiteboard with his laptop in hand.

We set out to write a short guide to switching on post-quantum TLS in NGINX Gateway Fabric. We ended up writing a guide to checking it’s already on, because it was, and to not switching it off by accident, because we did. If you want the background first (what the December 2026 warnings say, and why the gateway is where this happens), start with Preparing for a post-quantum world with NGINX Gateway Fabric.

All of the output below comes from one test cluster:

  • NGINX Gateway Fabric on kind;
  • an NGINX data plane built with OpenSSL 3.5.9;
  • a client running OpenSSL 3.5.10.

Step 1: check the OpenSSL version NGINX runs with

Hybrid post-quantum key exchange (X25519MLKEM768) arrived as an OpenSSL 3.5 default, so the OpenSSL version matters more than the NGINX version:

$ kubectl exec -n pqc deploy/gw-wild-nginx -c nginx -- nginx -V 2>&1 | grep -i openssl
built with OpenSSL 3.5.9 29 Sep 2026

You need 3.5 or later. If the output also shows a “running with” version, that’s the one that counts.

Step 2: test it from a client

You need a client built with OpenSSL 3.5 or later. On macOS, the openssl command is actually LibreSSL and can’t run this test. Use Homebrew’s openssl@3, or run the command from a container, which is what we did.

First, connect without choosing a group, to see what an ordinary OpenSSL 3.5 client gets:

$ openssl s_client -connect <gateway-address>:443 -servername app.example.com \
    </dev/null 2>/dev/null | grep -E 'group|Temp Key'
Negotiated TLS1.3 group: X25519MLKEM768

Then test the two cases separately. Forcing the hybrid group proves the gateway accepts it:

$ openssl s_client -connect <gateway-address>:443 -servername app.example.com \
    -tls1_3 -groups X25519MLKEM768 </dev/null 2>/dev/null | grep -E 'group|Temp Key'
Negotiated TLS1.3 group: X25519MLKEM768

Forcing a classical group proves that clients without post-quantum support can still connect:

$ openssl s_client -connect <gateway-address>:443 -servername app.example.com \
    -tls1_3 -groups X25519 </dev/null 2>/dev/null | grep -E 'group|Temp Key'
Peer Temp Key: X25519, 253 bits

The grep matches two patterns because OpenSSL reports the two cases differently. Hybrid groups appear as Negotiated TLS1.3 group:. Classical groups appear as Peer Temp Key:. Our first version of this command grepped only for group, and the classical test looked as if it had returned nothing.

If the forced hybrid test prints Negotiated TLS1.3 group: <NULL>, the handshake failed. To see why, run the same command without 2>/dev/null and without the grep. OpenSSL writes the error to stderr, and in our case it was:

...:error:0A000410:SSL routines:ssl3_read_bytes:ssl/tls alert handshake failure:...

That usually means a key exchange setting on the Gateway is excluding the hybrid group. Step 3 shows where to look.

If your curl is built with OpenSSL 3.5, this also shows the negotiated group:

$ curl -sv -o /dev/null https://app.example.com/ 2>&1 | grep 'SSL connection'

Run the tests against every hostname on the Gateway, not just one. Key exchange groups are shared across a port, but other settings aren’t. nginx.org/ssl-protocols applies per hostname, so a hostname limited to TLS 1.2 gets no hybrid key exchange at all. And a hostname on a passthrough listener or another port may behave completely differently.

Step 3: find the setting that actually applies

The nginx.org/ssl-ecdh-curve listener option (added in NGINX Gateway Fabric 2.7) sets the key exchange groups NGINX offers. It only takes effect on the HTTPS listener without a hostname, and from there it applies to every hostname on the port. On listeners with a hostname it’s silently ignored. The Gateway still reports Accepted, Programmed and ResolvedRefs as True. The companion post explains why: OpenSSL picks the groups before NGINX knows the hostname.

The case to watch for is a no-hostname listener with an older, classical-only list. On our gw-wild Gateway, we set prime256v1:secp384r1 on the no-hostname listener and X25519MLKEM768:X25519 on the app.example.com listener. You can see which value NGINX actually used in the configuration it loaded:

$ kubectl exec -n pqc deploy/gw-wild-nginx -c nginx -- nginx -T 2>/dev/null \
    | grep -nE 'listen .*ssl|ssl_ecdh_curve|server_name '
214:    listen 443 ssl default_server;
217:    ssl_ecdh_curve prime256v1:secp384r1;
222:    listen 443 ssl;
225:    ssl_ecdh_curve X25519MLKEM768:X25519;
231:    server_name app.example.com;
259:    listen 443 ssl;
262:    ssl_ecdh_curve prime256v1:secp384r1;
268:    server_name ~^;

Line 217, in the default_server block, decides the key exchange for every hostname on port 443. Line 225 is never used. The last block (server_name ~^) is where NGINX Gateway Fabric routes requests for the no-hostname listener; it doesn’t affect the handshake. A default client connecting to app.example.com got Peer Temp Key: ECDH, prime256v1, 256 bits, and a client offering only the hybrid group couldn’t connect at all.

If a Gateway only has listeners with a hostname, the default_server block contains ssl_reject_handshake on; and no ssl_ecdh_curve, so OpenSSL’s defaults apply, and those include X25519MLKEM768.

Adding a no-hostname listener to a Gateway that has hostname listeners on the same port sets an OverlappingTLSConfig condition (reason OverlappingHostnames) on them. That’s expected; the Gateway stays Accepted and Programmed.

To check every Gateway in a cluster at once:

$ kubectl get gateways -A -o json | jq -r '
    .items[] | .metadata as $m | .spec.listeners[]
    | select(.tls != null and (.tls.mode // "Terminate") == "Terminate")
    | [$m.namespace, $m.name, .name, .port, (.hostname // "<none>"),
       (.tls.options["nginx.org/ssl-ecdh-curve"] // "-"),
       (.tls.options["nginx.org/ssl-protocols"] // "-")] | @tsv'
pqc   gw-blog2     https          443  app.example.com  auto                   TLSv1.3
pqc   gw-hostonly  https          443  app.example.com  prime256v1             -
pqc   gw-wild      https-default  443  <none>           prime256v1:secp384r1   -
pqc   gw-wild      https-app      443  app.example.com  X25519MLKEM768:X25519  -

Read the output like this:

  • A row with <none> and a curve list without MLKEM switches post-quantum off for every hostname on that port. Here, that’s gw-wild. The value auto is the exception: it tells NGINX to use OpenSSL’s defaults, which include the hybrid group.
  • A curve value on a row with a hostname has no effect, whatever it says. Here, that’s gw-blog2, gw-hostonly and gw-wild/https-app.
  • nginx.org/ssl-protocols is applied per hostname, so any value without TLSv1.3 disables hybrid key exchange for that hostname.

If you use SnippetsFilter or SnippetsPolicy, check those too:

$ kubectl get snippetsfilters,snippetspolicies -A -o yaml \
  | grep -nE 'ssl_ecdh_curve|ssl_conf_command|ssl_protocols'

Step 4: if you must set groups, keep OpenSSL’s tiers

Most Gateways don’t need a group list at all. We got two things wrong when we set one, and both are hard to spot.

First mistake: the list was incomplete. We set X25519MLKEM768:X25519:prime256v1 on the no-hostname listener, and a client that only supported P-384 was refused. An explicit list replaces OpenSSL’s whole default set, and the defaults include P-384. Adding secp384r1 fixed that.

Second mistake: the list was flat. OpenSSL’s own default isn’t a simple list. It’s a set of tiers separated by /, with the hybrid group in the top tier:

?*X25519MLKEM768 / ?*X25519:?secp256r1 / ?X448:?secp384r1:?secp521r1 / ?ffdhe2048:?ffdhe3072

When a client supports the top tier but sent its first key share for something lower, OpenSSL asks it to retry with the better group. A flat colon-separated list loses that. The server just takes the first listed group it already has a key share for.

To see it, we ran a client that supports X25519MLKEM768 but sends its first key share for X25519:

$ openssl s_client -connect <gateway-address>:443 -servername app.example.com \
    -tls1_3 -groups '*X25519:X25519MLKEM768' </dev/null 2>/dev/null | grep -E 'group|Temp Key'

Effective ssl_ecdh_curveHow we set itResult
none (OpenSSL default)nothing setNegotiated TLS1.3 group: X25519MLKEM768
X25519MLKEM768:X25519:prime256v1:secp384r1Gateway listener optionPeer Temp Key: X25519, 253 bits
X25519MLKEM768 / X25519:prime256v1:secp384r1SnippetsPolicy (below)Negotiated TLS1.3 group: X25519MLKEM768

Current browsers send a hybrid key share first, so they aren’t affected. Other clients that support the hybrid group but guess classical first get downgraded without any error.

The Gateway option can’t express tiers. NGINX Gateway Fabric rejected every value containing / with UnsupportedValue. If you need an explicit list, set it with a SnippetsPolicy instead. Snippets are disabled by default; enable them with the Helm value nginxGateway.snippets.enable=true.

apiVersion: gateway.nginx.org/v1alpha1
kind: SnippetsPolicy
metadata:
  name: pq-groups
  namespace: pqc
spec:
  targetRefs:
  - group: gateway.networking.k8s.io
    kind: Gateway
    name: gw-wild
  snippets:
  - context: http
    value: ssl_ecdh_curve "X25519MLKEM768 / X25519:prime256v1:secp384r1";

The http context places the directive in the http block of the NGINX configuration, outside any server block, so every server block inherits it, including the default server. That also avoids the hostname problem from step 3. In our tests it worked on a Gateway that had a no-hostname listener and on one with only hostname listeners.

Two cautions for this approach:

  • Remove nginx.org/ssl-ecdh-curve from the no-hostname listener. A value set there overrides the snippet for the whole port.
  • List every group your clients need. Our list still left out X448 and secp521r1, which the default includes, and clients offering only those were refused.

Step 5 (optional): require post-quantum for a sensitive service

To refuse clients that can’t do hybrid key exchange, give the service its own Gateway, or at least its own port. Then restrict the listener without a hostname on that port:

  listeners:
  - name: https-default
    port: 443
    protocol: HTTPS
    tls:
      mode: Terminate
      certificateRefs:
      - name: default-tls
      options:
        nginx.org/ssl-protocols: "TLSv1.3"
        nginx.org/ssl-ecdh-curve: "X25519MLKEM768"

If the dedicated Gateway only has a hostname listener, these options are silently ignored (step 3). Add a no-hostname listener as above, or set the group with a SnippetsPolicy instead.

In our tests, every hostname on the port returned handshake failure to clients offering only X25519, and refused TLS 1.2 clients.

This list has only one group, so there are no tiers to lose (step 4), and the Gateway option is fine.

If you follow CNSA 2.0, it specifies ML-KEM-1024 rather than ML-KEM-768. OpenSSL 3.5 includes a hybrid for that, SecP384r1MLKEM1024. We tested the Gateway option set to SecP384r1MLKEM1024:X25519MLKEM768:

  • an OpenSSL 3.5 client asking for SecP384r1MLKEM1024 negotiated it;
  • a default client still got X25519MLKEM768.

That’s a flat two-group list, so step 4’s caveat applies within it. A client that supports both but sends an X25519MLKEM768 key share first gets X25519MLKEM768, not SecP384r1MLKEM1024. Both are post-quantum, so nothing is downgraded to classical. If you need clients pushed to ML-KEM-1024 whenever they support it, put the two groups in separate tiers with a SnippetsPolicy. We didn’t test that variant.

Browsers don’t offer SecP384r1MLKEM1024 yet, so for public-facing services keep X25519MLKEM768 in the list.

Before switching strict mode on for real traffic, run step 6 for a while, so you know how many clients it would turn away.

Step 6: measure what real clients negotiate

Tests from your own machine show what the gateway can do. To see what clients actually negotiate, add $ssl_curve to the access log by editing the NginxProxy resource your GatewayClass already references. With a default Helm install, that’s nginx-gateway-proxy-config in the nginx-gateway namespace:

spec:
  logging:
    accessLog:
      escape: json
      format: '{"time":"$time_iso8601","host":"$host","status":"$status","tls":"$ssl_protocol","group":"$ssl_curve","reused":"$ssl_session_reused"}'

Applying this triggers a rolling restart of every NGINX pod that uses that NginxProxy. Plan for that rather than applying it in the middle of the day.

Then count:

$ kubectl logs -n pqc deploy/gw-blog2-nginx -c nginx \
    | jq -rR 'fromjson? | .group // empty' | sort | uniq -c | sort -rn
      3 X25519MLKEM768
      2 X25519
      1 secp384r1

Anything other than an MLKEM group is a classical connection. TLS 1.2 connections can’t use the hybrid groups, so they show up as a classical group such as X25519; our TLS 1.2 test handshakes negotiated X25519. The tls field separates them from TLS 1.3 clients that chose a classical group.

Two caveats:

  • Each line is a request, not a connection, so a busy keep-alive connection is counted many times.
  • Failed handshakes never reach the access log, and neither do TCP/TLS (stream) listeners.

We also checked whether session resumption would muddy the numbers. A resumed TLS 1.3 session logged "reused":"r" and still "group":"X25519MLKEM768". That’s because OpenSSL resumes TLS 1.3 sessions with a fresh key exchange (psk_dhe_ke) by default. A PSK-only resumption (psk_ke) wouldn’t do a new key exchange.

When the tests give confusing results

  • Something in front of the gateway terminates TLS. If a CDN or cloud load balancer terminates TLS, your s_client tests and your clients negotiate with it, not with NGINX. A Layer 4 load balancer doesn’t affect the result.
  • Hybrid fails but classical works, and the Gateway looks fine. A hybrid ClientHello is about 1 KB larger and usually spans two packets. Check firewalls and other middleboxes before changing NGINX.
  • A hostname on a TLS passthrough listener. NGINX doesn’t terminate those connections, so the result comes from the backend’s TLS stack.

Backend connections and certificates aren’t covered by these checks. The companion post covers both.

Summary

On a current NGINX Gateway Fabric data plane, hybrid post-quantum key exchange is already the default, and one openssl s_client command confirms it. The thing to watch is nginx.org/ssl-ecdh-curve: only the value on the listener without a hostname counts, and a list without an MLKEM group switches post-quantum off for the whole port. Even a list that includes the hybrid group can downgrade some clients, so leave it unset unless you need it, and use a tiered list in a SnippetsPolicy if you do. Run the jq audit from step 3 across your clusters, and add $ssl_curve to your access logs so you can see the numbers for real traffic.

Further reading