slackhq/nebula · error
invalid curve for PKCS#11: %s
Error message
invalid curve for PKCS#11: %s
What it means
nebula-cert's `keytext`/key generation path rejected the -curve value because PKCS#11 mode only supports P256. When -pkcs11 is set, any curve other than "P256" returns this error before any key material is generated.
Source
Thrown at cmd/nebula-cert/keygen.go:61
if !isP11 {
if err = mustFlagString("out-key", cf.outKeyPath); err != nil {
return err
}
} else if *cf.outKeyPath != "" {
return newHelpErrorf("cannot set -out-key with -pkcs11")
}
if err = mustFlagString("out-pub", cf.outPubPath); err != nil {
return err
}
var pub, rawPriv []byte
var curve cert.Curve
if isP11 {
switch *cf.curve {
case "P256":
curve = cert.Curve_P256
default:
return fmt.Errorf("invalid curve for PKCS#11: %s", *cf.curve)
}
} 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")
}
pub, rawPriv = x25519Keypair()
curve = cert.Curve_CURVE25519
case "P256":
pub, rawPriv = p256Keypair()
curve = cert.Curve_P256
default:
return fmt.Errorf("invalid curve: %s", *cf.curve)
}
}
var claims ioClaimsView on GitHub (pinned to dd8f660c0a)
Solutions
- Add `-curve P256` to the keygen command when using -pkcs11.
- Remove -pkcs11 if local (software) key generation was intended.
- Verify the HSM supports P256 before choosing PKCS#11 mode.
- Note Curve25519 is additionally blocked under FIPS 140 enforcement, so P256 is the only valid PKCS#11 curve.
Example fix
// before nebula-cert keygen -pkcs11 -curve 25519 -out-key host.key -out-pub host.pub // after nebula-cert keygen -pkcs11 -curve P256 -out-key host.key -out-pub host.pub
Defensive patterns
Strategy: validation
Validate before calling
#!/bin/sh if [ -n "$P11" ] && [ "$CURVE" != "P256" ]; then echo "PKCS#11 requires -curve P256" >&2 exit 1 fi
Type guard
func validP11Curve(curve string) bool {
return curve == "P256"
} Prevention
- Always pair -pkcs11 with -curve P256.
- Remember Curve25519 is disallowed for PKCS#11 (and under FIPS 140-only).
- Validate the HSM supports P256 before automating keygen.
When it happens
Trigger: Running `nebula-cert keygen -pkcs11 ...` with -curve set to 25519/X25519/Curve25519/CURVE25519 (or any value other than P256).
Common situations: Reusing a non-PKCS#11 keygen command line (which defaults to Curve25519) after adding the -pkcs11 flag; HSM hardware that only supports 25519; copying an older script that omitted -curve P256.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- invalid curve for PKCS#11: %s
- invalid curve: %s
- invalid curve: %s
- invalid curve: %s
- error while creating PKCS#11 client: %w
AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03).
Data as JSON: /api/errors/74ba9b51640f1ae7.
Report an issue: GitHub.