Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach step ca init about --key-password-file #1106

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions command/ca/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Action: cli.ActionFunc(initAction),
Usage: "initialize the CA PKI",
UsageText: `**step ca init**
[**--root**=<file>] [**--key**=<file>] [**--pki**] [**--ssh**]
[**--root**=<file>] [**--key**=<file>] [**--key-password-file**=<file>] [**--pki**] [**--ssh**]
[**--helm**] [**--deployment-type**=<name>] [**--name**=<name>]
[**--dns**=<dns>] [**--address**=<address>] [**--provisioner**=<name>]
[**--admin-subject**=<string>] [**--provisioner-password-file**=<file>]
Expand All @@ -57,6 +57,10 @@
Usage: "The path of an existing key <file> of the root certificate authority.",
EnvVar: step.IgnoreEnvVar,
},
cli.StringFlag{
Name: "key-password-file",
Usage: `The path to the <file> containing the password to decrypt the existing root certificate key.`,
},
cli.BoolFlag{
Name: "pki",
Usage: "Generate only the PKI without the CA configuration.",
Expand Down Expand Up @@ -240,10 +244,14 @@
case root == "" && key != "":
return errs.RequiredWithFlag(ctx, "key", "root")
case root != "" && key != "":
opts := []pemutil.Options{}
if keyPasswordFile := ctx.String("key-password-file"); keyPasswordFile != "" {
opts = append(opts, pemutil.WithPasswordFile(keyPasswordFile))

Check warning on line 249 in command/ca/init.go

View check run for this annotation

Codecov / codecov/patch

command/ca/init.go#L247-L249

Added lines #L247 - L249 were not covered by tests
}
if rootCrt, err = pemutil.ReadCertificate(root); err != nil {
return err
}
if rootKey, err = pemutil.Read(key); err != nil {
if rootKey, err = pemutil.Read(key, opts...); err != nil {

Check warning on line 254 in command/ca/init.go

View check run for this annotation

Codecov / codecov/patch

command/ca/init.go#L254

Added line #L254 was not covered by tests
return err
}
case ra != "" && ra != apiv1.CloudCAS && ra != apiv1.StepCAS:
Expand Down
Loading