diff --git a/gui/chains.go b/gui/chains.go index 2f198a4..2230a4d 100644 --- a/gui/chains.go +++ b/gui/chains.go @@ -33,8 +33,7 @@ type IssuerLoc struct { // From boulder: issuance/issuer.go type IssuerConfig struct { - UseForRSALeaves bool `json:"useForRSALeaves"` - UseForECDSALeaves bool `json:"useForECDSALeaves"` + Active bool `json:"active"` IssuerURL string `validate:"required,url" json:"issuerURL,omitempty"` OCSPURL string `validate:"required,url" json:"ocspURL,omitempty"` @@ -56,14 +55,13 @@ type CAConfig struct { // CertDetails contains info about each certificate for use in the GUI type CertDetails struct { - CertFile string - BaseName string - Subject string - IsRoot bool - UseForRSA bool - UseForECDSA bool - NotAfter string - Details string + CertFile string + BaseName string + Subject string + IsRoot bool + ActiveIssuer bool + NotAfter string + Details string } type CertChain struct { @@ -139,8 +137,7 @@ func enhanceChains(chains []CertChain) []CertChain { for k := 0; k < len(chains); k++ { for n := 0; n < len(chains[k].IssuerCerts); n++ { if chains[k].IssuerCerts[n].CertFile == rawChains[i].Location.CertFile { - chains[k].IssuerCerts[n].UseForRSA = rawChains[i].UseForRSALeaves - chains[k].IssuerCerts[n].UseForECDSA = rawChains[i].UseForECDSALeaves + chains[k].IssuerCerts[n].ActiveIssuer = rawChains[i].Active certFile := locateFile(rawChains[i].Location.CertFile) if d, err := getCertFileDetails(certFile); err == nil { chains[k].IssuerCerts[n].Details = d @@ -235,7 +232,7 @@ func getChains() []CertChain { return chains } -func setUseForLeavesFile(filename, forRSA, forECDSA string) error { +func setUseForLeavesFile(filename, active string) error { caConf, err := os.Open(filename) if err != nil { fmt.Println(err) @@ -251,30 +248,20 @@ func setUseForLeavesFile(filename, forRSA, forECDSA string) error { } // Make sure that the named certificate(s) exist - foundRSA := false - foundECDSA := false + foundActive := false for i := 0; i < len(result.CA.Issuance.Issuers); i++ { - if strings.Contains(result.CA.Issuance.Issuers[i].Location.CertFile, forRSA) { - foundRSA = true - } - if strings.Contains(result.CA.Issuance.Issuers[i].Location.CertFile, forECDSA) { - foundECDSA = true + if strings.Contains(result.CA.Issuance.Issuers[i].Location.CertFile, active) { + foundActive = true } } - if !foundRSA { - return errors.New("certificate '" + forRSA + "' not found in ca file") - } - if !foundECDSA { - return errors.New("certificate '" + forECDSA + "' not found in ca file") + if !foundActive { + return errors.New("certificate '" + active + "' not found in ca file") } // Now set the flags for the named certificate(s) for i := 0; i < len(result.CA.Issuance.Issuers); i++ { - if forRSA != "" { - result.CA.Issuance.Issuers[i].UseForRSALeaves = strings.Contains(result.CA.Issuance.Issuers[i].Location.CertFile, forRSA) - } - if forECDSA != "" { - result.CA.Issuance.Issuers[i].UseForECDSALeaves = strings.Contains(result.CA.Issuance.Issuers[i].Location.CertFile, forECDSA) + if active != "" { + result.CA.Issuance.Issuers[i].Active = strings.Contains(result.CA.Issuance.Issuers[i].Location.CertFile, active) } } @@ -302,25 +289,22 @@ func setUseForLeavesFile(filename, forRSA, forECDSA string) error { return nil } -func setUseForLeaves(forRSA, forECDSA string) error { +func setUseForLeaves(active string) error { if err := exec.Command("cp", "-f", caConfFile, caConfFile+"_BAK").Run(); err != nil { return errors.New("could not create ca backup file: " + err.Error()) } - if err := setUseForLeavesFile(caConfFile, forRSA, forECDSA); err != nil { + if err := setUseForLeavesFile(caConfFile, active); err != nil { exec.Command("mv", caConfFile+"_BAK", caConfFile).Run() return err } exec.Command("rm", caConfFile+"_BAK").Run() - if forRSA != "" { - viper.Set("certs.issuerRSA", forRSA) + if active != "" { + viper.Set("certs.activeIssuer", active) } - if forECDSA != "" { - viper.Set("certs.issuerECDSA", forECDSA) - } - if forRSA != "" || forECDSA != "" { + if active != "" { viper.WriteConfig() } diff --git a/gui/dashboard.go b/gui/dashboard.go index 3fb096b..4e55af0 100644 --- a/gui/dashboard.go +++ b/gui/dashboard.go @@ -194,6 +194,7 @@ func _parseComponents(data string) []Component { if len(parts) < 6 { components = append(components, Component{Name: "Boulder (ACME)"}) components = append(components, Component{Name: "Consul (Boulder)"}) + components = append(components, Component{Name: "pkilint (Boulder)"}) components = append(components, Component{Name: "LabCA Application"}) components = append(components, Component{Name: "LabCA Controller"}) components = append(components, Component{Name: "MySQL Database"}) @@ -261,8 +262,19 @@ func _parseComponents(data string) []Component { consulClass = "" } + pkilint, err := time.Parse(time.RFC3339Nano, parts[6]) + pkilintReal := "" + pkilintNice := "stopped" + pkilintClass := "error" + if err == nil { + pkilintReal = pkilint.Format("02-Jan-2006 15:04:05 MST") + pkilintNice = humanize.RelTime(pkilint, time.Now(), "", "") + pkilintClass = "" + } + components = append(components, Component{Name: "Boulder (ACME)", Timestamp: boulderReal, TimestampRel: boulderNice, Class: boulderClass}) components = append(components, Component{Name: "Consul (Boulder)", Timestamp: consulReal, TimestampRel: consulNice, Class: consulClass}) + components = append(components, Component{Name: "pkilint (Boulder)", Timestamp: pkilintReal, TimestampRel: pkilintNice, Class: pkilintClass}) components = append(components, Component{Name: "LabCA Application", Timestamp: labcaReal, TimestampRel: labcaNice, Class: labcaClass}) components = append(components, Component{Name: "LabCA Controller", Timestamp: svcReal, TimestampRel: svcNice, Class: svcClass}) components = append(components, Component{Name: "MySQL Database", Timestamp: mysqlReal, TimestampRel: mysqlNice, Class: mysqlClass}) @@ -472,6 +484,9 @@ func parseDockerStats(data string) []AjaxStat { if strings.Contains(docker.Name, "-bconsul-") { stat.Name = "Consul (Boulder)" } + if strings.Contains(docker.Name, "-bpkilint-") { + stat.Name = "pkilint (Boulder)" + } if strings.Contains(docker.Name, "labca-gui-") { stat.Name = "LabCA Application" } diff --git a/gui/main.go b/gui/main.go index d5213b3..22ac88b 100644 --- a/gui/main.go +++ b/gui/main.go @@ -1078,6 +1078,7 @@ func (res *Result) ManageComponents(w http.ResponseWriter, r *http.Request, acti (components[i].Name == "Boulder (ACME)" && (action == "boulder-start" || action == "boulder-stop" || action == "boulder-restart")) || (components[i].Name == "LabCA Application" && action == "labca-restart") || (components[i].Name == "Consul (Boulder)" && action == "consul-restart") || + (components[i].Name == "pkilint (Boulder)" && action == "pkilint-restart") || (components[i].Name == "MySQL Database" && action == "mysql-restart") { res.Timestamp = components[i].Timestamp res.TimestampRel = components[i].TimestampRel @@ -1203,7 +1204,7 @@ func updateLeaveIssuersHandler(w http.ResponseWriter, r *http.Request) { Error string }{Success: true} - if err := setUseForLeaves(r.Form.Get("rsa"), r.Form.Get("ecdsa")); err != nil { + if err := setUseForLeaves(r.Form.Get("active")); err != nil { res.Success = false res.Error = err.Error() } else { @@ -1359,6 +1360,7 @@ func _managePost(w http.ResponseWriter, r *http.Request) { "cert-export", "mysql-restart", "consul-restart", + "pkilint-restart", "nginx-reload", "nginx-restart", "svc-restart", @@ -1552,6 +1554,18 @@ func _manageGet(w http.ResponseWriter, r *http.Request) { components[i].Buttons = append(components[i].Buttons, btn) } + if components[i].Name == "pkilint (Boulder)" { + components[i].LogURL = "" + components[i].LogTitle = "" + + btn := make(map[string]interface{}) + btn["Class"] = "btn-warning" + btn["Id"] = "pkilint-restart" + btn["Title"] = "Restart the internal pkilint helper" + btn["Label"] = "Restart" + components[i].Buttons = append(components[i].Buttons, btn) + } + if components[i].Name == "MySQL Database" { components[i].LogURL = "" components[i].LogTitle = "" @@ -3549,4 +3563,4 @@ func main() { } else { log.Fatal(srv.ListenAndServe()) } -} \ No newline at end of file +} diff --git a/gui/templates/views/manage.tmpl b/gui/templates/views/manage.tmpl index a4a0d18..c3fb821 100644 --- a/gui/templates/views/manage.tmpl +++ b/gui/templates/views/manage.tmpl @@ -165,8 +165,7 @@ Subject - Issue RSA - Issue ECDSA + Active {{ range $item := .CertificateChains }} @@ -179,7 +178,6 @@ download - @@ -198,8 +196,7 @@ download - - + @@ -527,10 +524,8 @@

Are you sure?