DEV Community

Alan Veras
Alan Veras

Posted on

Checking post-quantum TLS with openssl s_client: the grep trap and the fallback trap

After the US ONCD, NSA and CISA statement on December 2, 2026, and the joint statement from Amazon, Apple, Google, Microsoft and others backing a fast move to post-quantum cryptography, I wanted a quick way to check one thing: does a given server already negotiate a post-quantum key exchange?

The key exchange is the part that matters for "harvest now, decrypt later": someone records encrypted traffic today and decrypts it once a large quantum computer exists. In TLS 1.3 the post-quantum option you will see most is X25519MLKEM768, a hybrid of classical X25519 and ML-KEM-768.

You can check it with plain openssl, no account and no SDK. It is one handshake. But on my machine two details made the result easy to misread, so this post is about those.

Step 0: can your client even offer it?

openssl version
openssl list -tls-groups | tr ':' '\n' | grep -i mlkem
Enter fullscreen mode Exit fullscreen mode

You need OpenSSL 3.5 or later, and X25519MLKEM768 in that list. I used OpenSSL 3.6.5 on Manjaro Linux.

Step 1: one handshake

host=kms.sa-east-1.amazonaws.com
openssl s_client -connect "$host:443" -servername "$host" \
  -groups X25519MLKEM768:X25519 </dev/null 2>&1 \
  | grep -E "^Protocol|Negotiated TLS1.3 group|Temp Key|Cipher is"
Enter fullscreen mode Exit fullscreen mode

-groups X25519MLKEM768:X25519 offers the hybrid first and classical X25519 as a fallback. The server picks one.

Trap 1: the grep that hides the classical result

If the server picks the hybrid group, OpenSSL 3.6.5 prints:

Negotiated TLS1.3 group: X25519MLKEM768
Enter fullscreen mode Exit fullscreen mode

If it picks classical X25519, that line is not there. The group shows up somewhere else:

Peer Temp Key: X25519, 253 bits
Enter fullscreen mode Exit fullscreen mode

If you grep only for Negotiated TLS1.3 group, a classical server gives you the protocol, the cipher and no group at all. That reads like "no data", not like "classical". That is why the grep above includes Temp Key.

And if the connection ends up on TLS 1.2 with RSA key transport, there is neither line. In a script I fall back from one to the other:

out="$(timeout 10 openssl s_client -connect "$host:443" \
      -servername "$host" -groups "$groups" </dev/null 2>&1)"
group="$(sed -n 's/^Negotiated TLS1.3 group: //p' <<<"$out" | head -1)"
[ -z "$group" ] && group="$(sed -n 's/^\(Peer\|Server\) Temp Key: //p' <<<"$out" | head -1)"
[ -z "$group" ] && group="none (RSA key transport)"
if [[ "$group" == *MLKEM* ]]; then status="PQ"; else status="NO_PQ"; fi
Enter fullscreen mode Exit fullscreen mode

The timeout 10 is there because s_client has no connect timeout of its own.

Trap 2: your fallback is not always what you think

To make sure the script could say "no", I added a control: the same handshake offering only X25519, which must come back classical.

Against sts.us-east-1.amazonaws.com it did come back classical, but not the way I expected. It did not finish TLS 1.3 with X25519. It negotiated TLS 1.2 with AES128-GCM-SHA256, which is RSA key transport: no ephemeral key, no forward secrecy.

h=sts.us-east-1.amazonaws.com
openssl s_client -connect $h:443 -servername $h -groups X25519 </dev/null 2>&1 | grep -E "^Protocol|Cipher is"
# TLS 1.2, AES128-GCM-SHA256
openssl s_client -connect $h:443 -servername $h -tls1_3 -groups X25519 </dev/null
# handshake fails
openssl s_client -connect $h:443 -servername $h -groups X25519:P-256 </dev/null 2>&1 | grep -E "^Protocol|Temp Key"
# TLS 1.3, P-256
Enter fullscreen mode Exit fullscreen mode

I repeated the X25519-only handshake on 56 public AWS endpoints: 29 fell back to TLS 1.2 like this, 27 stayed on TLS 1.3 with X25519. I did not find AWS documentation that explains it, so I am not guessing why.

How much it matters is narrower than it looks. OpenSSL's defaults also offer P-256, and with P-256 the same endpoint stays on TLS 1.3. Only a client that offers X25519 alone gets the weaker connection, and it gets it silently, not as an error. I don't know how common those clients are.

The lesson for testing: when you restrict what the client offers, check the protocol and cipher too, not just the group.

Make the test able to fail

A script that only ever prints "PQ" proves nothing. I ran three controls next to the real hosts:

Control Expected
a known host, offering only X25519 NO_PQ
does-not-exist.invalid (reserved, never resolves) DNS_FAIL
192.0.2.1 (TEST-NET, never routed) TIMEOUT

All three came back as expected.

What one handshake does not tell you

  • It measures your client. The server can prefer ML-KEM and your app can still connect classically, because your SDK, CLI or browser has to offer it.
  • One name, many servers. Each name resolves to several IPs and one handshake reaches one of them.
  • Only the key exchange. Every certificate I saw on AWS endpoints was RSA 2048. Post-quantum key exchange protects recorded traffic; it does not make the server's identity post-quantum.

Where I used it

I ran this on the home pages of seven Brazilian banks (all seven picked X25519MLKEM768) and on 56 public AWS endpoints in sa-east-1 and us-east-1 (46 picked ML-KEM, 10 stayed classical). The AWS results, compared with AWS's own readiness table, are in my case study on AWS Builder Center: https://builder.aws.com/content/3MyD8Ger9bI25UO3EdvcyCEK4dn/is-your-aws-connection-post-quantum-i-checked

https://github.com/alan-veras/aws-pqc-tls-check

Have you checked what your own HTTP client or SDK offers? I'd like to know which version first gave you X25519MLKEM768.

This article was created with the help of AI. The commands and results come from runs on my own machine on December 3, 2026.

Top comments (0)