From 714a38d612d2e2a2fa566157dfbb819c5926b1ff Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Wed, 10 Dec 2025 21:13:51 +0100 Subject: [PATCH] Fix error messages for consistency in ca.go and certdb.go --- ca.go | 8 ++++---- certdb.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ca.go b/ca.go index 24877e2..9eb0671 100644 --- a/ca.go +++ b/ca.go @@ -462,7 +462,7 @@ func issueSingleCertificate(def CertificateDefinition, i int, n int) (bool, erro // Check if the certificate is in database, fail if it is. if caState.FindByName(def.Name, false) != nil { - return false, fmt.Errorf("certificate %s already exists and is valid.", def.Name) + return false, fmt.Errorf("certificate %s already exists and is valid", def.Name) } // Initialize Subject if not specified @@ -634,7 +634,7 @@ Certificate generated: // If saving CA state fails, we still return success for the certificate issuance fmt.Printf("WARNING: %v\n", err) fmt.Println("CA state not saved, but certificate issued and saved successfully.") - return true, fmt.Errorf("Error saving CA state: %v", err) + return true, fmt.Errorf("error saving CA state: %v", err) } return true, nil @@ -655,12 +655,12 @@ func ProvisionCertificates(filePath string) error { // Load certificates provisioning configuration from the file (HCL syntax) err = certDefs.LoadFromFile(filePath) if err != nil { - return fmt.Errorf("Error loading certificates file: %v", err) + return fmt.Errorf("error loading certificates file: %v", err) } // The certificate provisioning file must contain at least one certificate definition if len(certDefs.Certificates) < 1 { - return fmt.Errorf("No certificates defined in %s", filePath) + return fmt.Errorf("no certificates defined in %s", filePath) } // We will be counting successes and errors diff --git a/certdb.go b/certdb.go index 182f41f..cad23dc 100644 --- a/certdb.go +++ b/certdb.go @@ -98,7 +98,7 @@ func SaveCAState() error { // UpdateCAStateAfterIssue updates the CA state JSON after issuing a certificate func (s *CAState) UpdateCAStateAfterIssue(serialType, name string, subject string, certType string, serialNumber any, validity time.Duration) error { if s == nil { - return fmt.Errorf("CAState is nil in UpdateCAStateAfterIssue. This indicates a programming error.") + return fmt.Errorf("CAState is nil in UpdateCAStateAfterIssue. This indicates a programming error") } issued := time.Now().UTC().Format(time.RFC3339) expires := time.Now().Add(validity).UTC().Format(time.RFC3339) @@ -135,7 +135,7 @@ func (s *CAState) AddCertificate(name, subject, certType, issued, expires, seria // RevokeCertificate revokes a certificate by serial number and reason code, updates state, and saves to disk func (s *CAState) RevokeCertificate(serial string, reason int) error { if s == nil { - return fmt.Errorf("CAState is nil in RevokeCertificate. This indicates a programming error.") + return fmt.Errorf("CAState is nil in RevokeCertificate. This indicates a programming error") } revoked := false revokedAt := time.Now().UTC().Format(time.RFC3339)