slackhq/nebula · error

error while converting ecdsa key: %s

Error message

error while converting ecdsa key: %s

What it means

Wraps a failure from (*ecdsa.PrivateKey).ECDH() when converting a freshly generated P256 private key to ecdh format to obtain raw encoded bytes in `nebula-cert ca`. The conversion only fails if the key is not on the expected curve or is otherwise invalid — effectively never with a key just generated on P256.

Source

Thrown at cmd/nebula-cert/ca.go:291

			}
			curve = cert.Curve_CURVE25519
			pub, rawPriv, err = ed25519.GenerateKey(rand.Reader)
			if err != nil {
				return fmt.Errorf("error while generating ed25519 keys: %s", err)
			}
		case "P256":
			var key *ecdsa.PrivateKey
			curve = cert.Curve_P256
			key, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
			if err != nil {
				return fmt.Errorf("error while generating ecdsa keys: %s", err)
			}

			// ecdh.PrivateKey lets us get at the encoded bytes, even though
			// we aren't using ECDH here.
			eKey, err := key.ECDH()
			if err != nil {
				return fmt.Errorf("error while converting ecdsa key: %s", err)
			}
			rawPriv = eKey.Bytes()
			pub = eKey.PublicKey().Bytes()
		default:
			return fmt.Errorf("invalid curve: %s", *cf.curve)
		}
	}

	t := &cert.TBSCertificate{
		Version:        version,
		Name:           *cf.name,
		Groups:         groups,
		Networks:       networks,
		UnsafeNetworks: unsafeNetworks,
		NotBefore:      time.Now(),
		NotAfter:       time.Now().Add(*cf.duration),
		PublicKey:      pub,
		IsCA:           true,

View on GitHub (pinned to dd8f660c0a)

Solutions

  1. Rerun the command — the failure implies an invalid key was generated
  2. Verify the Go version and crypto package are unmodified (no vendored crypto patches)
  3. Check for FIPS-mode interactions with ecdh conversion and align Go/FIPS configuration
  4. Report to maintainers with the wrapped error if reproducible
Defensive patterns

Strategy: try-catch

Try / catch

out, err := exec.Command("nebula-cert", "ca", "-curve", "P256", ...).CombinedOutput()
if err != nil && strings.Contains(string(out), "error while converting ecdsa key") {
	log.Printf("ecdsa->ecdh conversion failed (crypto stack issue): %s", out)
	return fmt.Errorf("crypto environment misconfigured: %s", out)
}

Prevention

When it happens

Trigger: nebula-cert ca -curve P256 where the ecdsa key produced by GenerateKey cannot be converted via key.ECDH(); in practice only reachable if crypto stack misbehaves (wrong curve, zeroed key, patched/failing crypto library).

Common situations: Custom or broken crypto builds (e.g. tampered/fips-disabled crypto implementations); Go crypto library bugs; practically never in stock builds.

Related errors


AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03). Data as JSON: /api/errors/b3143e6f8d42c503. Report an issue: GitHub.