Post-quantum TLS on agentgateway: how to turn it on and prove it works
How to secure agentgateway traffic with the hybrid X25519MLKEM768 key exchange, on listeners and backend connections, standalone or on Kubernetes, and how to prove each step with OpenSSL.

Our commitment to post-quantum cryptography in agentgateway
Traffic through an AI gateway carries prompts, tool calls, credentials and model output, and some of it needs to stay private for years. An attacker can record encrypted traffic today and decrypt it once quantum computers are strong enough. Post-quantum key exchange closes that gap now.
agentgateway has supported post-quantum key exchange since v1.2.0 (PR #1725), and v1.8.1 turns it on by default for every HTTPS listener. Making the gateway lead with it on backend connections is merged (PR #4670), opt-in ML-KEM-1024 for CNSA 2.0 is in review (PR #4677), and ML-DSA post-quantum certificates already work.
The NSA’s December 2 advisory, Immediate Actions to Push Toward Post-Quantum, tells operators to move TLS services to TLS 1.3 and turn on post-quantum key exchange where it is available, using the hybrids defined in RFC 10024. This post shows how to do that on agentgateway.
agentgateway supports the hybrid X25519MLKEM768, which combines classical X25519 with ML-KEM-768 (FIPS 203). A session recorded today stays safe unless an attacker breaks both X25519 and ML-KEM.
Here is what to do, with a test after each step that proves it worked.
What to do
- Check that your listeners negotiate the hybrid. In v1.8.1 they already do.
- Require it on listeners where all your clients support it.
- Make the gateway lead with it on connections to your backends.
- If you follow CNSA 2.0, plan for ML-KEM-1024, which is coming as an opt-in option.
You don’t need to change your certificates for any of this. The steps are the same whether you run agentgateway as a standalone binary or on Kubernetes, so jump to Standalone or Kubernetes.
Before you start
You need agentgateway v1.8.1 built with the aws-lc-rs crypto backend. The official release builds use it. The optional SymCrypt backend has no ML-KEM, so the hybrid isn’t available there (#3130).
To run the tests you need OpenSSL 3.5 or newer on your machine, because earlier versions can’t offer X25519MLKEM768.
Standalone
Check that your binary uses aws-lc-rs:
./agentgateway --versionLook for "crypto_backend": "aws-lc-rs" in the output. Then create a throwaway CA and a certificate for localhost for the tests:
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 ..Step 1: Check that your listener negotiates the hybrid
There is nothing to turn on. Any HTTPS listener in v1.8.1 offers the hybrid. Save this as 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"Test it. Start the gateway and connect with a client that offers the hybrid:
./agentgateway -f config-frontend.yaml &
openssl s_client -connect 127.0.0.1:8443 -servername localhost \
-tls1_3 -groups X25519MLKEM768 -brief -CAfile certs/ca.pemYou should see:
Protocol version: TLSv1.3
Verification: OK
Negotiated TLS1.3 group: X25519MLKEM768
Negotiated TLS1.3 group: X25519MLKEM768 is the proof. OpenSSL 3.5 offers the hybrid first by default, so a plain openssl s_client without -groups gets the same result. The admin UI doesn’t show the negotiated group, so use OpenSSL to check.
Older clients still connect. They fall back to a classical group:
| Client offers | Negotiated |
|---|---|
| OpenSSL 3.5 defaults | X25519MLKEM768 |
X25519MLKEM768 | X25519MLKEM768 |
X25519 only | X25519 |
secp256r1 only | prime256v1 (P-256) |
TLS 1.2 client (-tls1_2) | X25519, ECDHE-ECDSA-AES256-GCM-SHA384 |
Run the same command with -groups X25519 and you get Peer Temp Key: X25519, 253 bits instead:

Step 2: Require post-quantum on a listener
Add two lines to the listener’s tls block:
tls:
cert: certs/cert.pem
key: certs/key.pem
minTLSVersion: TLS_V1_3
keyExchangeGroups: [X25519_MLKEM768]Clients that can’t do the hybrid are now refused instead of falling back. The supported group names are X25519, P-256, P-384 and X25519_MLKEM768.
Test it. Restart the gateway. The command from Step 1 still connects with X25519MLKEM768. A classical client is refused:
openssl s_client -connect 127.0.0.1:8443 -servername localhost \
-tls1_3 -groups X25519 -brief -CAfile certs/ca.pemssl/tls alert handshake failure ... SSL alert number 40
Check your clients before you turn this on in production. Clients that only offer X25519 or secp256r1 get the same alert, and TLS 1.2 clients can’t connect at all. Browsers, Go, and curl built on OpenSSL 3.5 or newer already offer the hybrid. A safe way to roll it out is to add an enforced listener on a separate port and move clients to it.
Step 3: Use post-quantum on connections to your backends
When agentgateway calls an upstream, the gateway is the TLS client. In v1.8.1 it sends an X25519 key share first. An upstream that prefers the hybrid has to ask for a retry, which costs a round trip, and an upstream that follows the client’s order settles on plain X25519. Make the gateway lead with the hybrid by setting keyExchangeGroups on backendTLS. Save this as config-backend.yaml:
binds:
- port: 8443
listeners:
- name: plain
protocol: HTTP
routes:
- policies:
backendTLS:
root: certs/ca.pem
hostname: localhost
keyExchangeGroups: [X25519_MLKEM768, X25519]
backends:
- host: 127.0.0.1:9443Keep X25519 in the list so classical upstreams still work. The gateway sends both key shares, so an upstream without ML-KEM picks X25519 in the same handshake. PR #4670 makes this the default in releases after v1.8.1.
Test it. Run an OpenSSL server as the upstream with -trace, so it prints the handshake, and send a request through the gateway:
openssl s_server -accept 9443 -cert certs/cert.pem -key certs/key.pem -www -trace
./agentgateway -f config-backend.yaml &
curl -s -o /dev/null -w 'HTTP %{http_code}\n' http://127.0.0.1:8443/The key exchange lines from s_server -trace should look like this:
ClientHello, Length=1465
extension_type=key_share(51), length=1258
NamedGroup: X25519MLKEM768 (4588)
NamedGroup: ecdh_x25519 (29)
ServerHello, Length=1206
extension_type=key_share(51), length=1124
NamedGroup: X25519MLKEM768 (4588)
The proof is one ClientHello, no retry, and X25519MLKEM768 in the ServerHello. The request returns HTTP 200.
keyExchangeGroups works on backendTLS in route policies, per-backend policies and AI provider policies. It can’t be combined with spiffe in the same backend TLS block.
Option: ML-KEM-1024
X25519MLKEM768 uses ML-KEM-768. CNSA 2.0, the NSA’s algorithm suite for National Security Systems, requires the larger ML-KEM-1024 for key exchange. If you run those systems or follow CNSA 2.0, ML-KEM-1024 is the option you want.
agentgateway is adding ML-KEM-1024 as an opt-in key exchange group, MLKEM1024, in PR #4677. It isn’t in v1.8.1, so check the release notes for the first release that includes it. It is ML-KEM-1024 on its own, not a hybrid with a classical group, and it is never used unless you list it.
Once you’re on that release, require it on a listener with the same keyExchangeGroups field:
tls:
cert: certs/cert.pem
key: certs/key.pem
minTLSVersion: TLS_V1_3
keyExchangeGroups: [MLKEM1024]The same value works on backendTLS. Browsers don’t offer ML-KEM-1024, so requiring it fits service-to-service traffic where you control both ends. OpenSSL 3.5 supports it, but doesn’t offer it by default.
Test it. Ask for the group explicitly:
openssl s_client -connect 127.0.0.1:8443 -servername localhost \
-tls1_3 -groups MLKEM1024 -brief -CAfile certs/ca.pemLook for Negotiated TLS1.3 group: MLKEM1024.
Kubernetes
On Kubernetes, the same settings go in an AgentgatewayPolicy. Listener settings live under spec.frontend.tls, backend settings under spec.backend.tls, and minTLSVersion: TLS_V1_3 becomes minProtocolVersion: "1.3". The group names are the same as in the standalone config.
The examples assume a Gateway named agentgateway-proxy in the agentgateway-system namespace with an HTTPS listener on port 443. For the tests, set your Gateway’s external address, the hostname on its certificate, and the CA that signed it:
export GW_ADDRESS=$(kubectl get gateway agentgateway-proxy -n agentgateway-system \
-o jsonpath='{.status.addresses[0].value}')
export GW_HOST=www.example.com
export GW_CA=ca.pemStep 1: Check that your Gateway negotiates the hybrid
There is nothing to turn on. An HTTPS listener on the v1.8.1 proxy offers the hybrid by default.
Test it. Connect with a client that offers the hybrid:
openssl s_client -connect $GW_ADDRESS:443 -servername $GW_HOST \
-tls1_3 -groups X25519MLKEM768 -brief -CAfile $GW_CAYou should see:
Protocol version: TLSv1.3
Verification: OK
Negotiated TLS1.3 group: X25519MLKEM768As with the standalone binary, older clients still connect and fall back to a classical group.
Step 2: Require post-quantum on the Gateway
Apply a policy that targets the Gateway. It covers every listener on it:
kubectl apply -f- <<EOF
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
name: pqc-frontend
namespace: agentgateway-system
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: agentgateway-proxy
frontend:
tls:
minProtocolVersion: "1.3"
keyExchangeGroups: ["X25519_MLKEM768"]
EOFTest it. The command from Step 1 still connects with X25519MLKEM768. A classical client is refused with alert 40:
openssl s_client -connect $GW_ADDRESS:443 -servername $GW_HOST \
-tls1_3 -groups X25519 -brief -CAfile $GW_CAssl/tls alert handshake failure ... SSL alert number 40The same rollout advice applies: check your clients first, because X25519-only, secp256r1-only and TLS 1.2 clients can no longer connect.
Step 3: Use post-quantum on connections to your backends
Apply a policy that targets the upstream Service and port, next to your other backend TLS settings:
kubectl apply -f- <<EOF
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
name: pqc-backend
namespace: agentgateway-system
spec:
targetRefs:
- group: ""
kind: Service
name: my-upstream
sectionName: "8443"
backend:
tls:
caCertificateRefs:
- name: my-upstream-ca
sni: my-upstream.example.com
keyExchangeGroups: ["X25519_MLKEM768", "X25519"]
EOFTest it. Send a request through the Gateway and confirm it still returns 200. To see the key exchange itself, run an OpenSSL server with -trace as the upstream, as in the standalone Step 3, and look for X25519MLKEM768 in the ServerHello.
If requests to the backend start failing after you apply the policy, check the proxy logs. When the crypto provider doesn’t support a listed group, or the policy also sets certificateSource: SPIFFE, the proxy rejects the backend TLS settings and every request to that backend fails, even though the policy status says Accepted:
kubectl logs -n agentgateway-system deploy/agentgateway-proxy | grep -i "backend TLS policy"Option: ML-KEM-1024
Opt-in ML-KEM-1024 is coming in PR #4677. See the standalone option for what it is and who it’s for. Once the release notes list MLKEM1024 for AgentgatewayPolicy, set it in the same field, keyExchangeGroups: ["MLKEM1024"], under spec.frontend.tls or spec.backend.tls.
Test it. Run openssl s_client against your Gateway with -groups MLKEM1024 and look for Negotiated TLS1.3 group: MLKEM1024.
Optional: post-quantum certificates
The steps above protect the key exchange, and your ECDSA or RSA certificates can stay as they are. If you also want post-quantum signatures, agentgateway v1.8.1 supports ML-DSA-44, ML-DSA-65 and ML-DSA-87 certificates (FIPS 204) for listener certificates, backend TLS verification and mTLS client certificates. No extra configuration is needed. Generate the key with openssl genpkey -algorithm ML-DSA-65 and use the certificate like any other.
Test it. Ask for an ML-DSA signature and check both the signature type and the group:
openssl s_client -connect 127.0.0.1:8443 -servername localhost \
-tls1_3 -sigalgs mldsa65 -brief -CAfile mldsa65/ca.pemSignature type: mldsa65
Verification: OK
Negotiated TLS1.3 group: X25519MLKEM768
Checklist
- You’re running the
aws-lc-rsbuild of agentgateway v1.8.1. openssl s_client -groups X25519MLKEM768against your listener or Gateway showsNegotiated TLS1.3 group: X25519MLKEM768.- You checked which clients can’t offer the hybrid before enforcing it.
- With enforcement on,
openssl s_client -groups X25519is refused with alert 40. - Backend TLS lists
X25519_MLKEM768first (backendTLSstandalone,spec.backend.tlson Kubernetes), and the upstream negotiatesX25519MLKEM768.
References
- NSA, Immediate Actions to Push Toward Post-Quantum (PP-26-4956, December 2026, Version 1.0)
- RFC 10024: PQ/T hybrid key agreement for TLS
- agentgateway PR #1725 (post-quantum key exchange), PR #4670 (hybrid first by default for backend connections), PR #4677 (opt-in ML-KEM-1024), #3130 (ML-KEM for the SymCrypt backend)
- Listener TLS settings in the agentgateway docs