Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func NewInitCommand() cli.Command {
cli.StringFlag{"province, st", "", "CA state/province", ""},
cli.StringFlag{"locality, l", "", "CA locality", ""},
cli.StringFlag{"key", "", "Path to private key PEM file. If blank, will generate new keypair.", ""},
cli.StringFlag{"out-name, on", "", "Name for output files without path and extension. If blank, CA common name will be used.", ""},
cli.BoolFlag{"stdout", "Print CA certificate to stdout in addition to saving file", ""},
},
Action: initAction,
Expand All @@ -60,6 +61,9 @@ func initAction(c *cli.Context) {
}

formattedName := strings.Replace(c.String("common-name"), " ", "_", -1)
if c.IsSet("out-name") {
formattedName = strings.Replace(c.String("out-name"), " ", "_", -1)
}

if depot.CheckCertificate(d, formattedName) || depot.CheckPrivateKey(d, formattedName) {
fmt.Fprintln(os.Stderr, "CA with specified name already exists!")
Expand Down
4 changes: 4 additions & 0 deletions cmd/request_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func NewCertRequestCommand() cli.Command {
cli.StringFlag{"ip", "", "IP address entries for subject alt name (comma separated)", ""},
cli.StringFlag{"domain", "", "DNS entries for subject alt name (comma separated)", ""},
cli.StringFlag{"key", "", "Path to private key PEM file. If blank, will generate new keypair.", ""},
cli.StringFlag{"out-name, on", "", "Name for output files without path and extension. If blank, Common name will be used.", ""},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer out to on

cli.BoolFlag{"stdout", "Print signing request to stdout in addition to saving file", ""},
},
Action: newCertAction,
Expand Down Expand Up @@ -82,6 +83,9 @@ func newCertAction(c *cli.Context) {
}

formattedName := strings.Replace(name, " ", "_", -1)
if c.IsSet("out-name") {
formattedName = strings.Replace(c.String("out-name"), " ", "_", -1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the string replace is potentially confusing and we should omit it. Just do formattedName = out-name. If the user specifies an out-name, we should use it directly.

}

if depot.CheckCertificateSigningRequest(d, formattedName) || depot.CheckPrivateKey(d, formattedName) {
fmt.Fprintln(os.Stderr, "Certificate request has existed!")
Expand Down