Security

How to migrate Go services to post-quantum cryptography

Capy team

Upgrade Go services to 1.26 for all three RFC 10024 hybrid TLS groups, or to 1.27 for ML-DSA certificates and TLS 1.3 signatures. Delete legacy CurvePreferences lists and GODEBUG=tlsmlkem=0 overrides, then assert ConnectionState.CurveID in a handshake test. Move signatures and JWTs off 256-bit curves and 2048-bit RSA to P-384 or RSA-3072 behind a dual-key window.

Which Go version do you need for post-quantum TLS and ML-DSA?

Migrating Go services to post-quantum cryptography starts with the Go toolchain, because Go ships TLS 1.3 hybrid key exchange and ML-DSA in the standard library. Under the December 2026 NSA post-quantum checklist, move TLS to RFC 10024 hybrids first and rotate signatures off 256-bit curves and 2048-bit RSA.

Go versionStandard library PQC supportGODEBUG disable
Go 1.24X25519MLKEM768 default, crypto/mlkemtlsmlkem=0
Go 1.25tls.ConnectionState.CurveIDtlsmlkem=0
Go 1.26SecP256r1MLKEM768, SecP384r1MLKEM1024 defaultstlssecpmlkem=0
Go 1.27August 19, 2026; crypto/mldsa, crypto/x509 ML-DSA, TLS 1.3 MLDSA44/65/87Same as 1.26

Scan each repo for 256-bit curves, RSA key generation, explicit CurvePreferences, and GODEBUG disables:

rg -n 'elliptic\.P256|ecdh\.P256|tls\.CurveP256' .
rg -n 'ed25519\.|rsa\.GenerateKey|CurvePreferences|tlsmlkem' .

Bump go and toolchain in go.mod, CI images, and Dockerfile builders to Go 1.26 for all three RFC 10024 hybrids, or Go 1.27 for ML-DSA. Delete legacy CurvePreferences slices that drop hybrids, and strip GODEBUG=tlsmlkem=0, GODEBUG=tlssecpmlkem=0, and //go:debug overrides.

How do you configure hybrid TLS 1.3 for Go HTTP and gRPC?

In crypto/tls, Go ignores the order of CurvePreferences and selects with its own preference order, so dropping classical curves forces hybrid-only handshakes. Pin hybrid-only CurvePreferences on internal endpoints once peers run Go 1.26 or later, knowing classical-only clients will fail. Keep a temporary fallback on public endpoints while tracking callers, then remove standalone tls.X25519 and tls.CurveP256 while keeping tls.X25519MLKEM768.

Define one shared HybridTLSConfig() helper in a transport package:

package transport

import "crypto/tls"

func HybridTLSConfig() *tls.Config {
	return &tls.Config{
		MinVersion: tls.VersionTLS13,
		CurvePreferences: []tls.CurveID{
			tls.X25519MLKEM768,
			tls.SecP384r1MLKEM1024,
		},
	}
}

Pass HybridTLSConfig() to http.Server.TLSConfig and http.Transport.TLSClientConfig inside NewHTTPClient(). For grpc-go, pass HybridTLSConfig() to credentials.NewTLS on clients, and have the gRPC server add its certificate chain to a copy of HybridTLSConfig() before credentials.NewTLS. See Post-quantum TLS 1.3 with hybrid key exchange for proxies and other runtimes.

How do you test Go hybrid TLS negotiation in CI?

Since Go 1.25, tls.ConnectionState.CurveID exposes the negotiated group on client responses and server requests. Build the httptest.NewUnstartedServer handshake test from the same HybridTLSConfig() and NewHTTPClient() the service uses, taking only the test certificate and trust root from httptest, so a later edit back to classical groups fails it. The test lives in package transport_test and also imports crypto/x509 and net/http/httptest:

func TestHybridTLSHandshake(t *testing.T) {
	h := http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
	s := httptest.NewUnstartedServer(h)
	s.TLS = transport.HybridTLSConfig()
	s.StartTLS()
	defer s.Close()

	c := transport.NewHTTPClient()
	roots := x509.NewCertPool()
	roots.AddCert(s.Certificate())
	c.Transport.(*http.Transport).TLSClientConfig.RootCAs = roots

	resp, err := c.Get(s.URL)
	if err != nil {
		t.Fatal(err)
	}
	defer resp.Body.Close()

	if got := resp.TLS.CurveID; got != tls.X25519MLKEM768 {
		t.Fatalf("got curve %v, want X25519MLKEM768", got)
	}
}

Run GODEBUG=tlsmlkem=0 go test ./... to confirm the test fails when X25519MLKEM768 is off, and GODEBUG=tlssecpmlkem=0 go test ./... if you also assert a SecP hybrid.

Run the Go PQC migration across repos with Capy

Prove the brief on one pilot repository, then let Capy run the remaining Go services:

  • One thread per repository with Captains. A Captain splits your brief across crew threads, one per repository, each opening and following its own pull request.
  • Real checks in isolated cloud microVMs. Each thread runs on its own isolated cloud machine with the repo cloned, running go test ./..., go vet ./..., and the TLS handshake checks before opening the pull request.
  • PR rules with Capy Review. Plain-English rules in AGENTS.md under ## Reviews, plus organization rules in Settings under Review, flag P-256, Ed25519, and sub-3072 RSA regressions on every pull request.
  • Weekly re-scans with Automations. A scheduled prompt re-scans for weak curves or GODEBUG disables and opens a pull request when it finds regressions. Capy never merges unless someone asks for that merge.

See How to run a code migration across many repositories with coding agents for the multi-repository pattern.

How do you migrate Go JWTs and signatures off P-256 to ML-DSA?

Until verifiers support ML-DSA, move elliptic.P256() to elliptic.P384(), 2048-bit rsa.GenerateKey to 3072, ed25519 to P-384, and jwt.SigningMethodES256 to jwt.SigningMethodES384 or jwt.SigningMethodPS384:

key, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
if err != nil {
	return err
}
token := jwt.NewWithClaims(jwt.SigningMethodES384, claims)
signed, err := token.SignedString(key)

Rotate keys behind a dual-key window so active tokens stay valid:

  1. Publish the P-384 or RSA-3072 public key beside the old one and deploy verifiers that accept both keys and both signing methods. A golang-jwt verifier pinned with WithValidMethods needs ES384 or PS384 added before signers switch.
  2. Switch signers to the new key and wait for active tokens or certificates to expire.
  3. Remove the old public key and signing path.

NIST IR 8547 deprecates quantum-vulnerable public-key cryptography after 2030 and disallows it after 2035. On Go 1.27, adopt ML-DSA on internal CAs and service-to-service TLS first, picking ML-DSA-87 and ML-KEM-1024 for CNSA 2.0 or ML-DSA-65 and ML-KEM-768 for commercial services. Most services never import crypto/mlkem unless encapsulating keys outside TLS. See Audit JWTs, SSH keys and certificates for post-quantum readiness and Block weak RSA and ECC in CI and PR review.

Frequently Asked Questions

Does Go enable post-quantum TLS key exchange by default?+
Yes. Go 1.24 enabled X25519MLKEM768 by default in crypto/tls, and Go 1.26 added SecP256r1MLKEM768 and SecP384r1MLKEM1024 unless CurvePreferences or GODEBUG=tlsmlkem=0 overrides them.
Is X25519MLKEM768 weak because X25519 is a 256-bit curve?+
No. X25519MLKEM768 is an RFC 10024 hybrid whose ML-KEM-768 half supplies the post-quantum security, and NSA advisory PP-26-4956 endorses it.
Why does Go ignore the order of tls.Config.CurvePreferences?+
CurvePreferences restricts allowed groups while crypto/tls picks with its own preference order. Dropping classical curves enforces hybrid-only handshakes.
How do you rotate Go JWT signing from ES256 to ES384 safely?+
Publish P-256 and P-384 public keys so verifiers accept ES256 and ES384, switch signers to jwt.SigningMethodES384, wait for old tokens to expire, then drop P-256.

Sources

  1. Go: Go 1.26 Release Notes
  2. Go: Go 1.27 Release Notes
  3. Go standard library: crypto/tls
  4. IETF: RFC 10024, Post-Quantum Traditional (PQ/T) Hybrid Key Agreement Mechanisms for TLS 1.3

Spotted something out of date? Tell us at support@capy.ai.

Fan out Go PQC upgrades across your repositories

Give one Captain your Go migration brief and let it run one thread per service repository through tests, vet and pull requests.