From 70fbdeab922918af3c487e44c8f1575422fe132e Mon Sep 17 00:00:00 2001 From: reservoir-cmyk Date: Sat, 5 Dec 2026 08:56:05 +0900 Subject: [PATCH] certificate create: default CA-profile keys (root-ca, intermediate-ca) to P-384 --- command/certificate/certificate.go | 2 +- command/certificate/create.go | 9 +++++++++ utils/cli.go | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/command/certificate/certificate.go b/command/certificate/certificate.go index 442b59dd..086d99ae 100644 --- a/command/certificate/certificate.go +++ b/command/certificate/certificate.go @@ -21,7 +21,7 @@ of private keys. ## EXAMPLES -Create a root certificate and private key using the default parameters (EC P-256 curve): +Create a root certificate and private key using the default parameters (EC P-384 curve): ''' $ step certificate create foo foo.crt foo.key --profile root-ca ''' diff --git a/command/certificate/create.go b/command/certificate/create.go index 5ab72823..3202f346 100644 --- a/command/certificate/create.go +++ b/command/certificate/create.go @@ -783,6 +783,15 @@ func parseOrCreateKey(ctx *cli.Context) (crypto.PublicKey, crypto.Signer, error) if err != nil { return nil, nil, err } + // Keys for CA certificates (the root-ca and intermediate-ca) + // profiles) default to the CA curve, unless a curve was + // explicitly requested. + if kty == "EC" && !ctx.IsSet("crv") && !ctx.IsSet("curve") { + switch ctx.String("profile") { + case profileRootCA, profileIntermediateCA: + crv = utils.DefaultECCurveForCA + } + } if insecureMode { // put keyutil in insecure mode, allowing RSA keys shorter than 2048 bits undoInsecure := keyutil.Insecure() defer undoInsecure() diff --git a/utils/cli.go b/utils/cli.go index 488a42cb..088ff63f 100644 --- a/utils/cli.go +++ b/utils/cli.go @@ -15,6 +15,9 @@ const DefaultRSASize = 2048 // DefaultECCurve sets the default curve for EC to P-256. const DefaultECCurve = "P-256" +// DefaultECCurveForCA sets the default curve for EC CA keys to P-384. +const DefaultECCurveForCA = "P-384" + // GetKeyDetailsFromCLI gets the key pair algorithm, curve, and size inputs // from the CLI context. func GetKeyDetailsFromCLI(ctx *cli.Context, insecure bool, ktyKey, curveKey, sizeKey string) (string, string, int, error) {