{"record":{"id":"03b61c6fe6b6e42a","repo":"slackhq/nebula","slug":"bytes-did-not-contain-a-proper-nebula-encrypted-ed","errorCode":null,"errorMessage":"bytes did not contain a proper nebula encrypted Ed25519/ECDSA private key banner","messagePattern":"bytes did not contain a proper nebula encrypted Ed25519/ECDSA private key banner","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cert/crypto.go","lineNumber":269,"sourceCode":"}\n\n// DecryptAndUnmarshalSigningPrivateKey will try to pem decode and decrypt an Ed25519/ECDSA private key with\n// the given passphrase, returning any other bytes b or an error on failure\nfunc DecryptAndUnmarshalSigningPrivateKey(passphrase, b []byte) (Curve, []byte, []byte, error) {\n\tvar curve Curve\n\n\tk, r := pem.Decode(b)\n\tif k == nil {\n\t\treturn curve, nil, r, fmt.Errorf(\"input did not contain a valid PEM encoded block\")\n\t}\n\n\tswitch k.Type {\n\tcase EncryptedEd25519PrivateKeyBanner:\n\t\tcurve = Curve_CURVE25519\n\tcase EncryptedECDSAP256PrivateKeyBanner:\n\t\tcurve = Curve_P256\n\tdefault:\n\t\treturn curve, nil, r, fmt.Errorf(\"bytes did not contain a proper nebula encrypted Ed25519/ECDSA private key banner\")\n\t}\n\n\tned, err := UnmarshalNebulaEncryptedData(k.Bytes)\n\tif err != nil {\n\t\treturn curve, nil, r, err\n\t}\n\n\tvar bytes []byte\n\tswitch ned.EncryptionMetadata.EncryptionAlgorithm {\n\tcase \"AES-256-GCM\":\n\t\tbytes, err = aes256Decrypt(passphrase, &ned.EncryptionMetadata.Argon2Parameters, ned.Ciphertext)\n\t\tif err != nil {\n\t\t\treturn curve, nil, r, err\n\t\t}\n\tdefault:\n\t\treturn curve, nil, r, fmt.Errorf(\"unsupported encryption algorithm: %s\", ned.EncryptionMetadata.EncryptionAlgorithm)\n\t}\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/cert/crypto.go#L251-L287","documentation":"After a PEM block is successfully decoded, DecryptAndUnmarshalSigningPrivateKey checks the PEM block Type against the known encrypted Nebula private key banners (EncryptedEd25519PrivateKeyBanner, EncryptedECDSAP256PrivateKeyBanner). This error means the PEM parsed fine but its type banner is not one of those, so the library refuses to treat it as an encrypted Nebula signing key.","triggerScenarios":"Calling DecryptAndUnmarshalSigningPrivateKey with a PEM block whose Type is e.g. 'CERTIFICATE', 'NEBULA X25519 PUBLIC KEY', 'OPENVPN PRIVATE KEY', or any unencrypted/foreign key banner instead of the encrypted Ed25519/ECDSA private key banner.","commonSituations":"Passing a certificate or public key PEM where the encrypted private key is expected, using an OpenSSL-generated key file instead of one from nebula-cert, or a key file from an older/other tool with a different banner naming.","solutions":["Confirm the PEM header is '-----BEGIN NEBULA ED25519 ENCRYPTED PRIVATE KEY-----' or '-----BEGIN NEBULA ECDSA P256 ENCRYPTED PRIVATE KEY-----'","Pass the correct file: an encrypted Nebula signing private key, not a cert or public key","Regenerate or re-encrypt the key with EncryptAndMarshalSigningPrivateKey / nebula-cert if it has a foreign banner"],"exampleFix":"// before\nb, _ := os.ReadFile(\"host.crt\") // PEM type CERTIFICATE\nk, _, _, err := cert.DecryptAndUnmarshalSigningPrivateKey(pass, b)\n// after\nb, _ := os.ReadFile(\"host.key\") // PEM type NEBULA ED25519 ENCRYPTED PRIVATE KEY\nk, _, _, err := cert.DecryptAndUnmarshalSigningPrivateKey(pass, b)","handlingStrategy":"validation","validationCode":"func isEncryptedSigningKey(b []byte) bool {\n\tblk, _ := pem.Decode(b)\n\tif blk == nil {\n\t\treturn false\n\t}\n\tswitch blk.Type {\n\tcase cert.EncryptedEd25519PrivateKeyBanner, cert.EncryptedECDSAP256PrivateKeyBanner:\n\t\treturn true\n\t}\n\treturn false\n}","typeGuard":null,"tryCatchPattern":"curve, key, rest, err := cert.DecryptAndUnmarshalSigningPrivateKey(pass, b)\nif err != nil {\n\tif strings.Contains(err.Error(), \"proper nebula encrypted\") {\n\t\treturn fmt.Errorf(\"wrong PEM type for encrypted signing key (got a different banner); check you are using the private key file: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Check the PEM BEGIN line matches the expected encrypted private key banner before calling","Do not pass certificates or public keys where an encrypted private key is expected","Generate keys only with nebula-cert or EncryptAndMarshalSigningPrivateKey so banners are correct"],"tags":["pem","banner-mismatch","key-management","go"],"backgroundTag":"pem-banner-mismatch","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"}