-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
69 lines (61 loc) · 1.62 KB
/
Copy pathmain.go
File metadata and controls
69 lines (61 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
func main() {
rootCmd := &cobra.Command{
Use: "mtls",
Short: "mTLS Certificate Management Tool",
Long: `A CLI tool for creating and managing mTLS certificates including Root CAs and server certificates.`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// Ensure certs directory exists
if err := os.MkdirAll("./certs", 0755); err != nil {
return err
}
// Initialize DB
_, err := InitDB("./certs/registry.db")
return err
},
}
// CA commands
caCmd := &cobra.Command{
Use: "ca",
Short: "Manage Root Certificate Authorities",
}
caCmd.AddCommand(createCACmd())
caCmd.AddCommand(listCACmd())
caCmd.AddCommand(signCSRCmd())
caCmd.AddCommand(revokeCmd())
caCmd.AddCommand(genCRLCmd())
// Certificate commands
certCmd := &cobra.Command{
Use: "cert",
Short: "Manage server and client certificates",
}
certCmd.AddCommand(createServerCertCmd())
certCmd.AddCommand(listServerCertsCmd())
certCmd.AddCommand(createClientCertCmd())
certCmd.AddCommand(listClientCertsCmd())
certCmd.AddCommand(inspectCmd())
certCmd.AddCommand(verifyCmd())
// Add commands to root
rootCmd.AddCommand(caCmd)
rootCmd.AddCommand(certCmd)
rootCmd.AddCommand(createTreeCmd())
rootCmd.AddCommand(dbCmd())
rootCmd.AddCommand(serverCmd())
// Version command
versionCmd := &cobra.Command{
Use: "version",
Short: "Print version information",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("mtls version 1.0.0")
},
}
rootCmd.AddCommand(versionCmd)
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}