slackhq/nebula · error
error while generating ecdsa keys: %s
Error message
error while generating ecdsa keys: %s
What it means
Wraps a failure from ecdsa.GenerateKey(elliptic.P256(), rand.Reader) when generating a P256 CA key in `nebula-cert ca`. Like the ed25519 case, this normally fails only when the OS cryptographic random source is unavailable, though P256 generation can additionally fail on malformed key rejection by the crypto stack.
Source
Thrown at cmd/nebula-cert/ca.go:284
return fmt.Errorf("error while getting public key with PKCS#11: %w", err)
}
} else {
switch *cf.curve {
case "25519", "X25519", "Curve25519", "CURVE25519":
if fips140.Enforced() {
return errors.New("use of Curve25519 is not allowed in FIPS 140-only mode")
}
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,View on GitHub (pinned to dd8f660c0a)
Solutions
- Inspect the wrapped error for the underlying rand/ecdsa failure reason
- Ensure /dev/urandom is present and readable in the execution environment
- Upgrade kernel/container so getrandom(2) works
- Retry the command; failures are almost always environmental and transient
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: ensure the OS random source is readable
if _, err := os.ReadFile("/dev/urandom"); err != nil {
return fmt.Errorf("entropy source unavailable: %w", err)
} Try / catch
out, err := exec.Command("nebula-cert", "ca", "-curve", "P256", ...).CombinedOutput()
if err != nil && strings.Contains(string(out), "error while generating ecdsa keys") {
log.Printf("P256 key generation failed: %s", out)
// check environment, then retry
} Prevention
- Check /dev/urandom availability in sandboxed runners
- Use stock Go builds; custom crypto builds can break ECDSA generation
- Retry once on transient entropy failures before alerting
When it happens
Trigger: nebula-cert ca -curve P256 when crypto/rand.Reader fails (getrandom(2) error, /dev/urandom inaccessible) or the ecdsa key generation loop cannot produce a valid key.
Common situations: Containers blocking /dev/urandom; kernels without getrandom; FIPS/libcrypto conflicts affecting P256; embedded systems with entropy starvation.
Related errors
- error while generating ed25519 keys: %s
- error while converting ecdsa key: %s
- key was not 32 bytes, is invalid ECDSA P256 private key
- key was not 32 bytes, is invalid ECDSA P256 private key
- error while getting public key with PKCS#11: %w
AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03).
Data as JSON: /api/errors/7dc33627ed48423d.
Report an issue: GitHub.