From 34fab7b3d0053cee14963b68a883720fc4994848 Mon Sep 17 00:00:00 2001 From: Toby Chui Date: Mon, 6 May 2024 19:06:26 +0800 Subject: [PATCH] Fixed cert upgrade panic - Fixed no config json cert upgrade panic bug --- src/cert.go | 9 +++++---- src/config.go | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/cert.go b/src/cert.go index 36c6287..89c8238 100644 --- a/src/cert.go +++ b/src/cert.go @@ -84,9 +84,10 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) { } } certInfoFilename := filepath.Join(tlsCertManager.CertStore, filename+".json") - certInfo, err := acme.LoadCertInfoJSON(certInfoFilename) - if err != nil { - SystemWideLogger.PrintAndLog("Could not Load CertInfoJson", certInfoFilename, err) + useDNSValidation := false //Default to false for HTTP TLS certificates + certInfo, err := acme.LoadCertInfoJSON(certInfoFilename) //Note: Not all certs have info json + if err == nil { + useDNSValidation = certInfo.UseDNS } thisCertInfo := CertInfo{ @@ -94,7 +95,7 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) { LastModifiedDate: modifiedTime, ExpireDate: certExpireTime, RemainingDays: expiredIn, - UseDNS: certInfo.UseDNS, + UseDNS: useDNSValidation, } results = append(results, &thisCertInfo) diff --git a/src/config.go b/src/config.go index 5978769..7fa1a11 100644 --- a/src/config.go +++ b/src/config.go @@ -155,7 +155,7 @@ func GetDefaultRootConfig() (*dynamicproxy.ProxyEndpoint, error) { */ func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) { - includeSysDBRaw, err := utils.GetPara(r, "includeDB") + includeSysDBRaw, _ := utils.GetPara(r, "includeDB") includeSysDB := false if includeSysDBRaw == "true" { //Include the system database in backup snapshot @@ -177,7 +177,7 @@ func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) { defer zipWriter.Close() // Walk through the folder and add files to the zip - err = filepath.Walk(folderPath, func(filePath string, fileInfo os.FileInfo, err error) error { + err := filepath.Walk(folderPath, func(filePath string, fileInfo os.FileInfo, err error) error { if err != nil { return err }