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
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.