slackhq/nebula · error
error while encrypting out-key: %s
Error message
error while encrypting out-key: %s
What it means
Wraps a failure from cert.EncryptAndMarshalSigningPrivateKey(curve, rawPriv, passphrase, kdfParams) when -encrypt is set in `nebula-cert ca`. The private key could not be encrypted and marshaled (e.g. KDF derivation or AEAD sealing failed), so the command aborts before writing the key file.
Source
Thrown at cmd/nebula-cert/ca.go:342
var c cert.Certificate
var b []byte
if isP11 {
c, err = t.SignWith(nil, curve, p11Client.SignASN1)
if err != nil {
return fmt.Errorf("error while signing with PKCS#11: %w", err)
}
} else {
c, err = t.Sign(nil, curve, rawPriv)
if err != nil {
return fmt.Errorf("error while signing: %s", err)
}
if *cf.encryption {
b, err = cert.EncryptAndMarshalSigningPrivateKey(curve, rawPriv, passphrase, kdfParams)
if err != nil {
return fmt.Errorf("error while encrypting out-key: %s", err)
}
} else {
b = cert.MarshalSigningPrivateKeyToPEM(curve, rawPriv)
}
err = writeOutput(*cf.outKeyPath, b, 0600, out)
if err != nil {
return fmt.Errorf("error while writing out-key: %s", err)
}
}
b, err = c.MarshalPEM()
if err != nil {
return fmt.Errorf("error while marshalling certificate: %s", err)
}
err = writeOutput(*cf.outCertPath, b, 0600, out)
if err != nil {View on GitHub (pinned to dd8f660c0a)
Solutions
- Ensure a valid non-empty passphrase is provided when -encrypt is set
- Check the wrapped error for KDF/AEAD specifics and adjust crypto settings (FIPS mode, kdf params)
- Drop -encrypt to write the key in plaintext PEM if protection is handled elsewhere
- Upgrade nebula if the wrapped error points to a known crypto-library incompatibility
Example fix
// before nebula-cert ca -encrypt -name "my ca" # empty passphrase reaches encryption // after nebula-cert ca -encrypt -name "my ca" # ensure -passphrase/-nonce supplied # or drop encryption: nebula-cert ca -name "my ca"
Defensive patterns
Strategy: validation
Validate before calling
if encrypt && (passphrase == "") {
return fmt.Errorf("-encrypt requires a non-empty passphrase")
} Try / catch
out, err := exec.Command("nebula-cert", "ca", "-encrypt", ...).CombinedOutput()
if err != nil && strings.Contains(string(out), "error while encrypting out-key") {
log.Printf("key encryption failed: %s", out)
return fmt.Errorf("could not encrypt key: %s", out)
} Prevention
- Always supply a non-empty passphrase when using -encrypt
- Keep flag combinations consistent (encrypt implies a passphrase source)
- Check FIPS/KDF compatibility if using restricted crypto modes
- Store passphrases in a secret manager, not inline in scripts
When it happens
Trigger: nebula-cert ca -encrypt ... where EncryptAndMarshalSigningPrivateKey fails: passphrase rejected by the crypto layer, unsupported curve for encryption, or internal KDF/AEAD failure (rare; usually indicates invalid inputs like an empty passphrase slipped past earlier checks).
Common situations: Scripting passes an empty or malformed passphrase via -nonce/-passphrase handling; FIPS-mode crypto rejecting the configured KDF parameters; inconsistent flag combinations (encryption enabled with stdio without passphrase).
Related errors
- invalid passphrase or corrupt private key
- out-key must be encrypted interactively
- error reading passphrase: %s
- no passphrase specified, remove -encrypt flag to write out-k
- error while getting public key with PKCS#11: %w
AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03).
Data as JSON: /api/errors/13fff599874c6bce.
Report an issue: GitHub.