slackhq/nebula · error

invalid curve for PKCS#11: %s

Error message

invalid curve for PKCS#11: %s

What it means

When a PKCS#11 token is used (-pkcs11/-p11url), nebula-cert ca only supports the P256 curve. Any other -curve value (e.g. 25519) is rejected with "invalid curve for PKCS#11: %s" because the PKCS#11 client implementation only implements P-256 key generation.

Source

Thrown at cmd/nebula-cert/ca.go:254

				}
			}

			if len(passphrase) == 0 {
				return fmt.Errorf("no passphrase specified, remove -encrypt flag to write out-key in plaintext")
			}
		}
	}

	var curve cert.Curve
	var pub, rawPriv []byte
	var p11Client *pkclient.PKClient

	if isP11 {
		switch *cf.curve {
		case "P256":
			curve = cert.Curve_P256
		default:
			return fmt.Errorf("invalid curve for PKCS#11: %s", *cf.curve)
		}

		p11Client, err = pkclient.FromUrl(*cf.p11url)
		if err != nil {
			return fmt.Errorf("error while creating PKCS#11 client: %w", err)
		}
		defer func(client *pkclient.PKClient) {
			_ = client.Close()
		}(p11Client)
		pub, err = p11Client.GetPubKey()
		if err != nil {
			return fmt.Errorf("error while getting public key with PKCS#11: %w", err)
		}
	} 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")

View on GitHub (pinned to dd8f660c0a)

Solutions

  1. Pass -curve P256 (exact spelling) when using PKCS#11.
  2. Remove the PKCS#11 flags if you want a non-P256 curve and software key generation.
  3. Check for case/format typos: only the literal string "P256" is accepted.

Example fix

// before
nebula-cert ca -name "ca" -p11url "p11://..." -curve 25519

// after
nebula-cert ca -name "ca" -p11url "p11://..." -curve P256
Defensive patterns

Strategy: validation

Validate before calling

if usingPKCS11 && *curve != "P256" {
    return fmt.Errorf("PKCS#11 requires -curve P256, got %s", *curve)
}

Try / catch

out, err := exec.Command("nebula-cert", "ca", args...).CombinedOutput()
if err != nil && strings.Contains(string(out), "invalid curve for PKCS#11") {
    // retry with -curve P256 or without PKCS#11 flags
    return err
}

Prevention

When it happens

Trigger: Running `nebula-cert ca -p11url <url> -curve 25519` (or any curve string other than exactly "P256") while PKCS#11 mode is enabled.

Common situations: Users whose HSM/setup defaults to Curve 25519 passing their usual -curve flag alongside PKCS#11 options, typos like p256/P-256 (case/format sensitive).

Related errors


AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03). Data as JSON: /api/errors/62f4009c58334864. Report an issue: GitHub.