{"record":{"id":"b3143e6f8d42c503","repo":"slackhq/nebula","slug":"error-while-converting-ecdsa-key-s","errorCode":null,"errorMessage":"error while converting ecdsa key: %s","messagePattern":"error while converting ecdsa key: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/nebula-cert/ca.go","lineNumber":291,"sourceCode":"\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:\n\t\t\treturn fmt.Errorf(\"invalid curve: %s\", *cf.curve)\n\t\t}\n\t}\n\n\tt := &cert.TBSCertificate{\n\t\tVersion:        version,\n\t\tName:           *cf.name,\n\t\tGroups:         groups,\n\t\tNetworks:       networks,\n\t\tUnsafeNetworks: unsafeNetworks,\n\t\tNotBefore:      time.Now(),\n\t\tNotAfter:       time.Now().Add(*cf.duration),\n\t\tPublicKey:      pub,\n\t\tIsCA:           true,","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/cmd/nebula-cert/ca.go#L273-L309","documentation":"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.","triggerScenarios":"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).","commonSituations":"Custom or broken crypto builds (e.g. tampered/fips-disabled crypto implementations); Go crypto library bugs; practically never in stock builds.","solutions":["Rerun the command — the failure implies an invalid key was generated","Verify the Go version and crypto package are unmodified (no vendored crypto patches)","Check for FIPS-mode interactions with ecdh conversion and align Go/FIPS configuration","Report to maintainers with the wrapped error if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"nebula-cert\", \"ca\", \"-curve\", \"P256\", ...).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"error while converting ecdsa key\") {\n\tlog.Printf(\"ecdsa->ecdh conversion failed (crypto stack issue): %s\", out)\n\treturn fmt.Errorf(\"crypto environment misconfigured: %s\", out)\n}","preventionTips":["Use unmodified Go crypto packages","Re-run once — the error implies a bad key was generated","Report persistent occurrences to maintainers; this is near-unreachable in stock builds"],"tags":["crypto","ecdsa","ecdh","p256"],"backgroundTag":"key-conversion-failed","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"}