{"record":{"id":"b84a2e14b2da445c","repo":"slackhq/nebula","slug":"error-while-generating-ed25519-keys-s","errorCode":null,"errorMessage":"error while generating ed25519 keys: %s","messagePattern":"error while generating ed25519 keys: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/nebula-cert/ca.go","lineNumber":277,"sourceCode":"\t\t\treturn fmt.Errorf(\"error while creating PKCS#11 client: %w\", err)\n\t\t}\n\t\tdefer func(client *pkclient.PKClient) {\n\t\t\t_ = client.Close()\n\t\t}(p11Client)\n\t\tpub, err = p11Client.GetPubKey()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error while getting public key with PKCS#11: %w\", err)\n\t\t}\n\t} else {\n\t\tswitch *cf.curve {\n\t\tcase \"25519\", \"X25519\", \"Curve25519\", \"CURVE25519\":\n\t\t\tif fips140.Enforced() {\n\t\t\t\treturn errors.New(\"use of Curve25519 is not allowed in FIPS 140-only mode\")\n\t\t\t}\n\t\t\tcurve = cert.Curve_CURVE25519\n\t\t\tpub, rawPriv, err = ed25519.GenerateKey(rand.Reader)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error while generating ed25519 keys: %s\", err)\n\t\t\t}\n\t\tcase \"P256\":\n\t\t\tvar key *ecdsa.PrivateKey\n\t\t\tcurve = cert.Curve_P256\n\t\t\tkey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error while generating ecdsa keys: %s\", err)\n\t\t\t}\n\n\t\t\t// ecdh.PrivateKey lets us get at the encoded bytes, even though\n\t\t\t// we aren't using ECDH here.\n\t\t\teKey, err := key.ECDH()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error while converting ecdsa key: %s\", err)\n\t\t\t}\n\t\t\trawPriv = eKey.Bytes()\n\t\t\tpub = eKey.PublicKey().Bytes()\n\t\tdefault:","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/cmd/nebula-cert/ca.go#L259-L295","documentation":"Wraps a failure from ed25519.GenerateKey(rand.Reader) when generating the CA key pair for the 25519 curve in `nebula-cert ca`. Ed25519 key generation essentially only fails when the system cryptographic random source is unavailable.","triggerScenarios":"nebula-cert ca -curve 25519 (or any 25519 alias) when crypto/rand.Reader cannot read from the OS entropy source (e.g. getrandom(2) fails, /dev/urandom unreadable, blocked entropy in constrained containers).","commonSituations":"Containers with restricted /dev/urandom access; kernels lacking getrandom; sandboxed environments blocking the random syscall; heavily depleted entropy pools on embedded Linux.","solutions":["Check the wrapped message for the underlying rand failure (e.g. 'getrandom: function not implemented')","Ensure /dev/urandom is available and readable inside the container/sandbox","Upgrade the kernel or container runtime so getrandom(2) is supported","Retry — transient entropy pressure typically resolves on retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: ensure the OS random source is readable\nif _, err := os.ReadFile(\"/dev/urandom\"); err != nil {\n\treturn fmt.Errorf(\"entropy source unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"nebula-cert\", \"ca\", \"-curve\", \"25519\", ...).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"error while generating ed25519 keys\") {\n\tlog.Printf(\"key generation failed (entropy?): %s\", out)\n\t// retry or fail fast with guidance on /dev/urandom\n}","preventionTips":["Verify /dev/urandom and getrandom(2) work in your container image","Run a one-line entropy preflight in CI before cert issuance","Avoid kernels/runtimes that stub out getrandom","Prefer P256 in FIPS-restricted environments where 25519 is blocked anyway"],"tags":["crypto","ed25519","entropy","cli"],"backgroundTag":"random-source-unavailable","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}