{"slug": "checking-post-quantum-tls-with-openssl-s-client-the-grep-trap-and-the-fallback", "title": "Checking post-quantum TLS with openssl s_client: the grep trap and the fallback trap", "summary": "A developer documented a method for checking whether a TLS server negotiates post-quantum key exchange using plain openssl s_client, and flagged two pitfalls that make results easy to misread: grepping only for the 'Negotiated TLS1.3 group' line hides classical X25519 fallbacks, and restricting the offered groups can silently drop a server to TLS 1.2 with RSA key transport. Testing 56 public AWS endpoints with an X25519-only offer, the developer found 29 fell back to TLS 1.2 while 27 stayed on TLS 1.3, with no AWS documentation found explaining the split.", "body_md": "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?\n\nThe 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.\n\nYou 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.\n\n```\nopenssl version\nopenssl list -tls-groups | tr ':' '\\n' | grep -i mlkem\n```\n\nYou need OpenSSL 3.5 or later, and `X25519MLKEM768` in that list. I used OpenSSL 3.6.5 on Manjaro Linux.\n\n```\nhost=kms.sa-east-1.amazonaws.com\nopenssl s_client -connect \"$host:443\" -servername \"$host\" \\\n  -groups X25519MLKEM768:X25519 </dev/null 2>&1 \\\n  | grep -E \"^Protocol|Negotiated TLS1.3 group|Temp Key|Cipher is\"\n```\n\n`-groups X25519MLKEM768:X25519` offers the hybrid first and classical X25519 as a fallback. The server picks one.\n\nIf the server picks the hybrid group, OpenSSL 3.6.5 prints:\n\n```\nNegotiated TLS1.3 group: X25519MLKEM768\n```\n\nIf it picks classical X25519, that line is not there. The group shows up somewhere else:\n\n```\nPeer Temp Key: X25519, 253 bits\n```\n\nIf 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`.\n\nAnd 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:\n\n```\nout=\"$(timeout 10 openssl s_client -connect \"$host:443\" \\\n      -servername \"$host\" -groups \"$groups\" </dev/null 2>&1)\"\ngroup=\"$(sed -n 's/^Negotiated TLS1.3 group: //p' <<<\"$out\" | head -1)\"\n[ -z \"$group\" ] && group=\"$(sed -n 's/^\\(Peer\\|Server\\) Temp Key: //p' <<<\"$out\" | head -1)\"\n[ -z \"$group\" ] && group=\"none (RSA key transport)\"\nif [[ \"$group\" == *MLKEM* ]]; then status=\"PQ\"; else status=\"NO_PQ\"; fi\n```\n\nThe `timeout 10` is there because `s_client` has no connect timeout of its own.\n\nTo make sure the script could say \"no\", I added a control: the same handshake offering **only** X25519, which must come back classical.\n\nAgainst `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.\n\n```\nh=sts.us-east-1.amazonaws.com\nopenssl s_client -connect $h:443 -servername $h -groups X25519 </dev/null 2>&1 | grep -E \"^Protocol|Cipher is\"\n# TLS 1.2, AES128-GCM-SHA256\nopenssl s_client -connect $h:443 -servername $h -tls1_3 -groups X25519 </dev/null\n# handshake fails\nopenssl s_client -connect $h:443 -servername $h -groups X25519:P-256 </dev/null 2>&1 | grep -E \"^Protocol|Temp Key\"\n# TLS 1.3, P-256\n```\n\nI 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.\n\nHow 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.\n\nThe lesson for testing: when you restrict what the client offers, check the protocol and cipher too, not just the group.\n\nA script that only ever prints \"PQ\" proves nothing. I ran three controls next to the real hosts:\n\n| Control | Expected | \n|---|---|\n| a known host, offering only X25519 | `NO_PQ` | \n| `does-not-exist.invalid` (reserved, never resolves) | `DNS_FAIL` | \n| `192.0.2.1` (TEST-NET, never routed) | `TIMEOUT` | \n\nAll three came back as expected.\n\nI 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://builder.aws.com/content/3MyD8Ger9bI25UO3EdvcyCEK4dn/is-your-aws-connection-post-quantum-i-checked)\n\n[https://github.com/alan-veras/aws-pqc-tls-check](https://github.com/alan-veras/aws-pqc-tls-check)\n\nHave you checked what your own HTTP client or SDK offers? I'd like to know which version first gave you `X25519MLKEM768`.\n\n*This article was created with the help of AI. The commands and results come from runs on my own machine on December 3, 2026.*", "url": "https://wpnews.pro/news/checking-post-quantum-tls-with-openssl-s-client-the-grep-trap-and-the-fallback", "canonical_source": "https://dev.to/victhors/checking-post-quantum-tls-with-openssl-sclient-the-grep-trap-and-the-fallback-trap-14be", "published_at": "2026-12-04 15:32:54+00:00", "updated_at": "2026-12-04 15:44:41.499142+00:00", "lang": "en", "topics": ["ai-safety"], "entities": ["OpenSSL", "AWS", "NSA", "CISA", "Amazon", "Apple", "Google", "Microsoft"], "also_reported_by": [], "takeaway": "When testing post-quantum TLS, grep for both 'Negotiated TLS1.3 group' and 'Peer Temp Key' and check the negotiated protocol and cipher, since an X25519-only offer silently dropped 29 of 56 AWS endpoints to TLS 1.2 with RSA key transport.", "recommendation": {"advice": "Check the negotiated protocol and cipher alongside the group when restricting client offers, and run a known-classical control host to confirm your script can actually report NO_PQ.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/checking-post-quantum-tls-with-openssl-s-client-the-grep-trap-and-the-fallback", "markdown": "https://wpnews.pro/news/checking-post-quantum-tls-with-openssl-s-client-the-grep-trap-and-the-fallback.md", "text": "https://wpnews.pro/news/checking-post-quantum-tls-with-openssl-s-client-the-grep-trap-and-the-fallback.txt", "jsonld": "https://wpnews.pro/news/checking-post-quantum-tls-with-openssl-s-client-the-grep-trap-and-the-fallback.jsonld"}}