package main import ( "flag" "log" "os" "git.cacert.org/cacert-gosigner/pkg/config" "git.cacert.org/cacert-gosigner/pkg/hsm" ) var ( commit string date string version string ) const ( defaultSignerConfigFile = "config.yaml" ) func main() { var ( showVersion bool signerConfigFile string setupMode bool ) log.SetFlags(log.Ldate | log.Lmicroseconds | log.Lshortfile | log.LUTC) log.Printf("cacert-gosigner %s (%s) - built %s\n", version, commit, date) flag.StringVar(&signerConfigFile, "caconfig", defaultSignerConfigFile, "signer configuration file") flag.BoolVar(&showVersion, "version", false, "show version") flag.BoolVar(&setupMode, "setup", false, "setup mode") flag.Parse() if showVersion { return } configFile, err := os.Open(signerConfigFile) if err != nil { log.Fatalf("could not open singer configuration file %s: %v", signerConfigFile, err) } caConfig, err := config.LoadConfiguration(configFile) if err != nil { log.Fatalf("could not load CA hierarchy: %v", err) } if setupMode { log.Print("running in setup mode") } ctx := hsm.SetupContext(caConfig, setupMode) err = hsm.EnsureCAKeysAndCertificates(ctx) if err != nil { log.Fatalf("could not ensure CA keys and certificates exist: %v", err) } if setupMode { return } log.Print("setup complete, starting signer operation") }