Skip to content
Quantum Aether/Post-quantum TLS in Go (crypto/tls): X25519MLKEM768 and the go.mod trap · Quantum Aether
Live platformالعربية

Post-quantum TLS in Go (crypto/tls): X25519MLKEM768 and the go.mod trap

Updated:

Short answer

Go enables post-quantum TLS (X25519MLKEM768) by default from Go 1.24, but only when the go line in your go.mod says 1.24 or newer. A binary built with a newer toolchain but go 1.23 in go.mod still negotiates plain X25519. Fix it with go mod edit -go=1.24 (or add godebug tlsmlkem=1), and don't pin CurvePreferences without tls.X25519MLKEM768.

Scan your site now, free

Domain or HTTP(S) URL. HTTPS port 443 is checked; paths and pasted URL ports are not scanned.

Go does TLS in its own standard library (crypto/tls), not through OpenSSL. Since Go 1.24 the default key exchange list includes the hybrid X25519MLKEM768, the same group Chrome and Firefox offer. Go 1.26 added SecP256r1MLKEM768 and SecP384r1MLKEM1024 to the defaults. This covers Go servers (net/http with ListenAndServeTLS) and Go clients (http.Get). Tools written in Go, such as Caddy and Traefik, follow the same rules in their own builds.

1. The trap: the go line in go.mod

Go keeps old behaviour for old modules. The defaults come from the go line of your main module, not from the toolchain you build with. We tested this with Go 1.27.3 against cloudflare.com:

go.mod "go 1.22"  →  X25519            (no post-quantum)
go.mod "go 1.23"  →  X25519            (no post-quantum)
go.mod "go 1.24"  →  X25519MLKEM768
go.mod "go 1.25"  →  X25519MLKEM768

So a service built with the newest Go can still be classical-only. Fix it by raising the line (go mod edit -go=1.24 or newer), or, if you cannot yet, by adding this line to go.mod:

godebug tlsmlkem=1

2. Don't pin CurvePreferences

When tls.Config.CurvePreferences is empty, Go uses its defaults. Old hardening code often sets an explicit list, which silently removes the hybrid group. Delete the field, or put the hybrid group first:

srv := &http.Server{
    Addr: ":443",
    TLSConfig: &tls.Config{
        CurvePreferences: []tls.CurveID{
            tls.X25519MLKEM768, tls.X25519, tls.CurveP256,
        },
    },
}
log.Fatal(srv.ListenAndServeTLS("cert.pem", "key.pem"))

In our test, a Go server with CurvePreferences: {X25519, CurveP256} negotiated only X25519 with a Go client that offered ML-KEM; with the list empty it negotiated X25519MLKEM768.

3. Check for GODEBUG in the environment

GODEBUG=tlsmlkem=0 (and tlssecpmlkem=0 for the Go 1.26 groups) turns the defaults off. It is sometimes set to work around old middleboxes that drop the larger ClientHello. Look in Dockerfiles, systemd units and Kubernetes manifests. Since Go 1.27, groups listed explicitly in CurvePreferences still work even with these settings.

4. Behind a proxy, the proxy decides

If nginx, a load balancer or a CDN terminates TLS in front of your Go service, configure that layer instead (nginx, AWS ALB/CloudFront).

Verify

Print the negotiated group from Go itself:

c, err := tls.Dial("tcp", "example.com:443", &tls.Config{})
if err != nil { log.Fatal(err) }
fmt.Println(c.ConnectionState().CurveID) // X25519MLKEM768

Or run the free scan; grade A means TLS 1.3 with a hybrid post-quantum key exchange. More ways to check: how to check any website.

Sources: Go crypto/tls documentation (Config.CurvePreferences), "GODEBUG history" and Go 1.27 release notes; our own tests with Go 1.27.3. Checked 2026-11-10.

Frequently asked questions

Why does my Go program built with a new Go version not use X25519MLKEM768?

Check, in order: the go line in go.mod (below 1.24 keeps the old defaults), a GODEBUG=tlsmlkem=0 in a Dockerfile, systemd unit or Kubernetes manifest, a CurvePreferences list without the hybrid, and a proxy or CDN that terminates TLS in front.

How do I check the negotiated group in Go?

After tls.Dial, print conn.ConnectionState().CurveID. It should show X25519MLKEM768.

What does GODEBUG tlsmlkem=0 do?

It turns the default hybrid off. Teams set it to work around middleboxes that drop the larger ClientHello: the X25519MLKEM768 client key share alone is 1,216 bytes (RFC 10024). Remove it once the middlebox is fixed.

Which post-quantum groups does Go support?

Go 1.24 added X25519MLKEM768 to the default key exchanges. Go 1.26 added SecP256r1MLKEM768 and SecP384r1MLKEM1024, also enabled by default (Go 1.26 release notes).

Scan your site now, free

Domain or HTTP(S) URL. HTTPS port 443 is checked; paths and pasted URL ports are not scanned.