← All articles

Post-quantum TLS in agentgateway: X25519MLKEM768 on the listener and to your backends

AI Security Networking agentgateway TLS 1.3 Post-Quantum ML-KEM X25519MLKEM768 OpenSSL
Share

By Sebastian Maniak

Here is what we’re deploying: a single agentgateway v1.8.1 binary with one HTTPS listener and one route that talks TLS to an upstream. Then we’ll look at the TLS handshake on both sides and check which key exchange group was negotiated.

The group is X25519MLKEM768, the hybrid of classical X25519 and ML-KEM-768 (FIPS 203). It is specified in RFC 10024 (August 2026), “Post-Quantum Traditional (PQ/T) Hybrid Key Agreement Mechanisms for TLS”, and IANA lists it as TLS supported group 4588 (0x11EC). The point of a hybrid is harvest-now-decrypt-later protection: a recorded session stays safe unless an attacker breaks both X25519 and ML-KEM.

Given the NSA’s latest advisory, Immediate Actions to Push Toward Post-Quantum (PP-26-4956, December 2026, Version 1.0), this is a good week to check what your gateways actually negotiate. The advisory, written for National Security Systems (NSS) owners, operators, and vendors, tells organizations to inventory where cryptography is used and to “Move TLS services to TLS 1.3 with approved crypto profiles,” enabling post-quantum settings where they are available. If a hybrid key exchange is needed, it says to configure it according to RFC 10024. A December 2 press release accompanies the advisory and tells organizations to prioritize implementation of Commercial National Security Algorithm Suite 2.0 (CNSA 2.0).

That is the motivation for this lab, not a compliance claim. The advisory’s appendix, and NSA’s CNSA 2.0 FAQ (October 2026, Version 2.2), require ML-KEM-1024 for key establishment on NSS, at all classification levels. RFC 10024 defines three hybrids; only SecP384r1MLKEM1024 uses ML-KEM-1024. agentgateway v1.8.1 negotiates X25519MLKEM768 — X25519 plus ML-KEM-768 — which is what browsers and OpenSSL 3.5 already offer first. That is useful general-purpose protection against harvest-now-decrypt-later collection. It is not a CNSA 2.0 configuration. The FAQ also says NSA will not require hybrid products for security purposes on NSS; the advisory does not change the FAQ’s NSS dates: CNSA 2.0 in new acquisitions from 1 January 2027, equipment that cannot support it phased out by 31 December 2030 unless granted an exception, and CNSA 2.0 mandated for use by 31 December 2031.

Short answer:

  • Listener (clients → agentgateway): yes, on by default in v1.8.1. If the client offers X25519MLKEM768, TLS 1.3 negotiates it. There is nothing to enable.
  • Backend (agentgateway → upstream): supported, but in v1.8.1 the gateway leads with classical X25519 unless you set keyExchangeGroups on the backend TLS policy. A change that makes the hybrid the default for backend connections (#4670) merged on Dec 2, after v1.8.1 was cut, so it is not in that release.

Everything below was run against the official agentgateway-linux-amd64 v1.8.1 release binary and OpenSSL 3.5.9.

What the binary is built with

./agentgateway --version
{
  "version": "1.8.1",
  "git_revision": "b22a72a024a29699b559ea8df2deb32c7bcb4ccf",
  "rust_version": "1.100.0",
  "build_profile": "release",
  "build_target": "x86_64-unknown-linux-musl",
  "crypto_backend": "aws-lc-rs",
  "crypto_fips": false
}

crypto_backend matters. agentgateway builds its rustls provider in crates/agentgateway/src/crypto/tls.rs, and the default key exchange list in crates/agentgateway/src/transport/tls.rs includes X25519_MLKEM768 for the aws-lc-rs backend, including the FIPS build. The optional SymCrypt backend has no ML-KEM, so on that backend the setting falls back to X25519 (tracked in #3130). The official release binary uses aws-lc-rs.

1. An HTTPS listener (no PQC config at all)

You need OpenSSL 3.5 or newer on the client side. Earlier versions can’t offer X25519MLKEM768.

Make a throwaway CA and a leaf for localhost:

mkdir -p certs && cd certs
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
  -keyout ca-key.pem -out ca.pem -days 30 -subj "/CN=agw-pqc-test-ca"
openssl req -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
  -keyout key.pem -out leaf.csr -subj "/CN=localhost"
openssl x509 -req -in leaf.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial \
  -out cert.pem -days 30 \
  -extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1\nbasicConstraints=CA:FALSE\nextendedKeyUsage=serverAuth,clientAuth")
cd ..

config-frontend.yaml:

# yaml-language-server: $schema=https://agentgateway.dev/schema/config
binds:
- port: 8443
  listeners:
  - name: pqc
    protocol: HTTPS
    tls:
      cert: certs/cert.pem
      key: certs/key.pem
    routes:
    - policies:
        directResponse:
          status: 200
          body: "hello over tls\n"

Run it and connect with a client that offers the hybrid group. -brief keeps the OpenSSL summary short; -CAfile is the test CA that signed the leaf, so verification comes back OK:

./agentgateway -f config-frontend.yaml &

openssl s_client -connect 127.0.0.1:8443 -servername localhost \
  -tls1_3 -groups X25519MLKEM768 -brief -CAfile certs/ca.pem

OpenSSL s_client negotiating TLS 1.3 with X25519MLKEM768 against the agentgateway v1.8.1 listener

The admin UI at :15000 shows the HTTPS listener on port 8443. It does not show the negotiated key exchange group, so the OpenSSL client is still the way to confirm PQC:

The agentgateway v1.8.1 admin UI Listeners page, with an HTTPS listener named pqc on port 8443

OpenSSL 3.5’s default group list already starts with X25519MLKEM768, so a plain openssl s_client with no -groups gets the same result.

Classical clients still connect

In TLS 1.3 the server picks the group from what the client offers. rustls, which agentgateway uses, picks the first group in the client’s list that it also supports. These are real results from the same listener:

client offersnegotiated
OpenSSL 3.5 defaultsX25519MLKEM768
X25519MLKEM768X25519MLKEM768
X25519MLKEM768:X25519X25519MLKEM768
X25519 onlyX25519
secp256r1 onlyprime256v1 (P-256)
TLS 1.2 client (-tls1_2)X25519, ECDHE-ECDSA-AES256-GCM-SHA384

The same listener, with the client offering only X25519:

openssl s_client -connect 127.0.0.1:8443 -servername localhost \
  -tls1_3 -groups X25519 -brief -CAfile certs/ca.pem

OpenSSL s_client offering only X25519 and falling back to a classical X25519 key exchange on the same listener

So you can leave the default in place and upgrade clients on their own schedule. Browsers, current curl builds on OpenSSL 3.5+, and Go already offer the hybrid first.

2. Pin the listener to the hybrid (or take it away)

The listener tls block has minTLSVersion, maxTLSVersion, cipherSuites and keyExchangeGroups. The group names are X25519, P-256, P-384 and X25519_MLKEM768.

To require TLS 1.3 and the hybrid group, so a client that can’t do post-quantum key exchange is refused instead of downgraded:

    tls:
      cert: certs/cert.pem
      key: certs/key.pem
      minTLSVersion: TLS_V1_3
      keyExchangeGroups: [X25519_MLKEM768]

A hybrid client still gets X25519MLKEM768:

OpenSSL s_client still negotiating X25519MLKEM768 against a listener pinned to TLS 1.3 and X25519_MLKEM768

A client that offers only X25519 is refused. OpenSSL reports TLS alert 40 (handshake failure):

OpenSSL s_client offering only X25519, rejected with a TLS handshake failure by the enforced listener

The same alert happens for a secp256r1-only client, and a TLS 1.2 client (-tls1_2) does not complete a handshake either (Cipher is (NONE)). That is a real outage for old clients, so roll it out knowingly.

The inverse also works. keyExchangeGroups: [X25519, P-256] turns the hybrid off, and a client offering only X25519MLKEM768 then gets a handshake failure, while OpenSSL’s default offer falls back to X25519:

== client groups: <openssl 3.5 default>
Peer Temp Key: X25519, 253 bits
== client groups: X25519MLKEM768
error:0A000410:SSL routines:ssl3_read_bytes:ssl/tls alert handshake failure

3. agentgateway as the client: backend TLS

When agentgateway connects to an upstream, it is the TLS client, and the roles flip. The server picks the group, but the client controls which key share it sends in its first message and in what order it lists groups.

config-backend.yaml sends plain HTTP in and TLS out to a local OpenSSL s_server:

binds:
- port: 8443
  listeners:
  - name: plain
    protocol: HTTP
    routes:
    - policies:
        backendTLS:
          root: certs/ca.pem
          hostname: localhost
      backends:
      - host: 127.0.0.1:9443

The upstream, with -trace so it prints what the gateway offered and what it picked:

openssl s_server -accept 9443 -cert certs/cert.pem -key certs/key.pem -www -trace
./agentgateway -f config-backend.yaml &
curl -s http://127.0.0.1:8443/

Default in v1.8.1

The screenshot below is an excerpt of the real s_server -trace output: the handshake-group lines only, no certificate hex dumps. The first ServerHello is 84 bytes with a 2-byte key_share — that is a HelloRetryRequest selecting group 4588.

openssl s_server -trace of a v1.8.1 default backend connection: first ClientHello offers only X25519, HelloRetryRequest selects X25519MLKEM768, second ClientHello completes the hybrid

The first ClientHello carries only an X25519 key share. OpenSSL 3.5 prefers the hybrid, so it sends a HelloRetryRequest, agentgateway answers with an ML-KEM share, and the handshake ends on X25519MLKEM768. That works, at the cost of an extra round trip. A server that goes by the client’s preference, like a rustls server, would just take the X25519 share, so don’t assume your upstream ends up post-quantum by default on v1.8.1. I tested only against OpenSSL.

Make the hybrid the first offer

Set keyExchangeGroups on backendTLS:

        backendTLS:
          root: certs/ca.pem
          hostname: localhost
          keyExchangeGroups: [X25519_MLKEM768, X25519]

openssl s_server -trace when backendTLS.keyExchangeGroups leads with X25519_MLKEM768: one ClientHello, no HelloRetryRequest, negotiated group X25519MLKEM768

One handshake, no retry. rustls sends the hybrid share plus a free X25519 share, so a classical upstream still works. I confirmed that by running s_server with -groups X25519 against the same gateway config:

 extension_type=key_share(51), length=1258
     NamedGroup: X25519MLKEM768 (4588)
     NamedGroup: ecdh_x25519 (29)
 ServerHello, Length=118
     NamedGroup: ecdh_x25519 (29)

The gateway got a normal 200 through to the upstream in both cases. The ClientHello is about 1.2 KB larger with the hybrid share, which is the usual cost of ML-KEM-768.

With keyExchangeGroups: [X25519] the gateway offers no hybrid at all and the handshake ends on ecdh_x25519, which is the right setting if an old middlebox chokes on the larger ClientHello.

keyExchangeGroups is available on backendTLS everywhere it appears in the config: route policies, per-backend policies and AI provider policies. It can’t be combined with spiffe in the same backend TLS block.

What this does not cover

  • This is key exchange only. Certificates in this lab are ECDSA P-256, so the signatures are classical. ML-DSA certificates aren’t part of what the hybrid group gives you.
  • I tested with aws-lc-rs on x86-64 Linux. I did not test the SymCrypt backend, which has no ML-KEM, or a FIPS build.
  • This post uses the standalone config. I did not test the Kubernetes (Gateway API / AgentgatewayPolicy) path.
  • I did not test against a public PQC endpoint or a rustls-based upstream.
  • This is not a CNSA 2.0 configuration. agentgateway v1.8.1 offers X25519, P-256, P-384, and X25519_MLKEM768. It does not offer ML-KEM-1024 or SecP384r1MLKEM1024.

Pull it together

If your goal is “post-quantum for clients hitting the gateway”, v1.8.1 already does it and you only need to verify with openssl s_client -groups X25519MLKEM768 (OpenSSL 3.5+). If your goal is “post-quantum to my backends”, set keyExchangeGroups: [X25519_MLKEM768, X25519] on backendTLS, or wait for a release that includes #4670.

References