Skip to content

Commit

Permalink
Add optional CN for build-ca cmd (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
liut authored Sep 3, 2023
1 parent 4db1026 commit 07d9871
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions cmd/easyrsa/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,23 @@ func Execute() {
}

var buildCa = &cobra.Command{
Use: "build-ca",
Short: "build ca cert/key",
Use: "build-ca [CN]",
Short: "build ca cert/key with optional CN",
Run: func(cmd *cobra.Command, args []string) {
_, err := pkiI.NewCa()
var options []pki.Option
if len(args) > 0 {
options = append(options, pki.CN(args[0]))
}
_, err := pkiI.NewCa(options...)
if err != nil {
fmt.Println(fmt.Errorf("can`t build ca pair: %s", err))
}
},
}

var buildServerKey = &cobra.Command{
Use: "build-server-key [cn]",
Short: "build server cert/key",
Use: "build-server-key CN",
Short: "build server cert/key with CN",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
options := []pki.Option{pki.Server()}
Expand All @@ -62,8 +66,8 @@ var buildServerKey = &cobra.Command{
}

var buildKey = &cobra.Command{
Use: "build-key [cn]",
Short: "build client cert/key",
Use: "build-key CN",
Short: "build client cert/key with CN",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
_, err := pkiI.NewCert(args[0], pki.Client())
Expand All @@ -74,8 +78,8 @@ var buildKey = &cobra.Command{
}

var revokeFull = &cobra.Command{
Use: "revoke-full [cn]",
Short: "revoke cert",
Use: "revoke-full CN",
Short: "revoke cert with CN",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
err := pkiI.RevokeAllByCN(args[0])
Expand Down

0 comments on commit 07d9871

Please sign in to comment.