You've already forked step-ca-cli
mirror of
https://github.com/smallstep/cli.git
synced 2025-08-09 03:22:43 +03:00
Merge branch 'master' into ssh-ca
This commit is contained in:
@@ -22,7 +22,7 @@ func initCommand() cli.Command {
|
||||
Action: cli.ActionFunc(initAction),
|
||||
Usage: "initialize the CA PKI",
|
||||
UsageText: `**step ca init**
|
||||
[**--root**=<path>] [**--key**=<path>] [**--pki**] [**--ssh**] [**--name**=<name>]
|
||||
[**--root**=<path>] [**--key**=<path>] [**--pki**] [**--ssh**] [**--name**=<name>]
|
||||
[**dns**=<dns>] [**address**=<address>] [**provisioner**=<name>]
|
||||
[**provisioner-password-file**=<path>] [**password-file**=<path>]
|
||||
[**with-ca-url**=<url>] [**no-db**]`,
|
||||
@@ -84,7 +84,7 @@ func initCommand() cli.Command {
|
||||
}
|
||||
|
||||
func initAction(ctx *cli.Context) (err error) {
|
||||
if err := assertCryptoRand(); err != nil {
|
||||
if err = assertCryptoRand(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -100,7 +100,6 @@ func initAction(ctx *cli.Context) (err error) {
|
||||
case len(root) == 0 && len(key) > 0:
|
||||
return errs.RequiredWithFlag(ctx, "key", "root")
|
||||
case len(root) > 0 && len(key) > 0:
|
||||
var err error
|
||||
if rootCrt, err = pemutil.ReadCertificate(root); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -145,7 +144,8 @@ func initAction(ctx *cli.Context) (err error) {
|
||||
}
|
||||
|
||||
if configure {
|
||||
names, err := ui.Prompt("What DNS names or IP addresses would you like to add to your new CA? (e.g. ca.smallstep.com[,1.1.1.1,etc.])",
|
||||
var names string
|
||||
names, err = ui.Prompt("What DNS names or IP addresses would you like to add to your new CA? (e.g. ca.smallstep.com[,1.1.1.1,etc.])",
|
||||
ui.WithValidateFunc(ui.DNS()), ui.WithValue(ctx.String("dns")))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -160,13 +160,15 @@ func initAction(ctx *cli.Context) (err error) {
|
||||
dnsNames = append(dnsNames, strings.TrimSpace(name))
|
||||
}
|
||||
|
||||
address, err := ui.Prompt("What address will your new CA listen at? (e.g. :443)",
|
||||
var address string
|
||||
address, err = ui.Prompt("What address will your new CA listen at? (e.g. :443)",
|
||||
ui.WithValidateFunc(ui.Address()), ui.WithValue(ctx.String("address")))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
provisioner, err := ui.Prompt("What would you like to name the first provisioner for your new CA? (e.g. you@smallstep.com)",
|
||||
var provisioner string
|
||||
provisioner, err = ui.Prompt("What would you like to name the first provisioner for your new CA? (e.g. you@smallstep.com)",
|
||||
ui.WithValidateNotEmpty(), ui.WithValue(ctx.String("provisioner")))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -187,11 +189,11 @@ func initAction(ctx *cli.Context) (err error) {
|
||||
if configure {
|
||||
// Generate provisioner key pairs.
|
||||
if len(provisionerPassword) > 0 {
|
||||
if err := p.GenerateKeyPairs(provisionerPassword); err != nil {
|
||||
if err = p.GenerateKeyPairs(provisionerPassword); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := p.GenerateKeyPairs(pass); err != nil {
|
||||
if err = p.GenerateKeyPairs(pass); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -211,7 +213,7 @@ func initAction(ctx *cli.Context) (err error) {
|
||||
} else {
|
||||
fmt.Println()
|
||||
fmt.Print("Copying root certificate... \n")
|
||||
if err := p.WriteRootCertificate(rootCrt, rootKey, pass); err != nil {
|
||||
if err = p.WriteRootCertificate(rootCrt, rootKey, pass); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("all done!")
|
||||
@@ -246,7 +248,7 @@ func initAction(ctx *cli.Context) (err error) {
|
||||
return p.Save(opts...)
|
||||
}
|
||||
|
||||
// assertCrytoRand asserts that a cryptographically secure random number
|
||||
// assertCryptoRand asserts that a cryptographically secure random number
|
||||
// generator is available, it will return an error otherwise.
|
||||
func assertCryptoRand() error {
|
||||
buf := make([]byte, 64)
|
||||
|
Reference in New Issue
Block a user