CAConfig global variable and refactoring.

This commit is contained in:
2025-07-27 20:45:05 +02:00
parent 10ec83273d
commit e2039550e0
3 changed files with 224 additions and 374 deletions

11
main.go
View File

@@ -9,9 +9,6 @@ import (
var Version = "dev"
// Global CA state variable
var GlobalCAState *CAState
func main() {
var configPath string
var overwrite bool
@@ -37,6 +34,10 @@ func main() {
Use: "initca",
Short: "Generate a new CA certificate and key",
Run: func(cmd *cobra.Command, args []string) {
if err := LoadCA(configPath); err != nil {
fmt.Printf("Error loading CA config: %v\n", err)
os.Exit(1)
}
InitCA(configPath, overwrite)
},
}
@@ -48,6 +49,10 @@ func main() {
Use: "issue",
Short: "Issue a new certificate (client, server, server-only, code-signing, email)",
Run: func(cmd *cobra.Command, args []string) {
if err := LoadCA(configPath); err != nil {
fmt.Printf("Error loading CA config: %v\n", err)
os.Exit(1)
}
IssueCertificate(configPath, subject, certType, validity, san, name, fromFile, overwrite, dryRun, verbose)
},
}