Enable X25519MLKEM768 in Go servers
From Go 1.24, crypto/tls offers and prefers X25519MLKEM768 by default. Most Go servers get post-quantum key exchange simply by building with a current Go.
Before you start
- Build with Go 1.24 or later:
go version. - If a load balancer or CDN terminates TLS in front of your Go server, configure that instead: your Go server only handles the connection behind it.
Option 1: leave CurvePreferences unset (simplest)
If your tls.Config has no CurvePreferences, Go chooses its default list, which puts X25519MLKEM768 first.
- Search your code for it:
grep -rn CurvePreferences . - If nothing sets it, rebuild with Go 1.24 or later and redeploy. Nothing else to change.
Option 2: list the groups yourself
If you need a fixed list:
- Put X25519MLKEM768 first in
CurvePreferences:
cfg := &tls.Config{
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{tls.X25519MLKEM768, tls.X25519, tls.CurveP256},
}
- Rebuild with Go 1.24 or later and redeploy.
Check it isn't switched off
The GODEBUG setting tlsmlkem=0 turns X25519MLKEM768 off. Make sure it isn't set in your environment or in your go.mod godebug block:
go env GODEBUG
grep -n godebug go.mod
Then scan your domain below.