Fixed cert upgrade panic

- Fixed no config json cert upgrade panic bug
This commit is contained in:
Toby Chui 2024-05-06 19:06:26 +08:00
parent 46817d0664
commit 34fab7b3d0
2 changed files with 7 additions and 6 deletions

View File

@ -84,9 +84,10 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
} }
} }
certInfoFilename := filepath.Join(tlsCertManager.CertStore, filename+".json") certInfoFilename := filepath.Join(tlsCertManager.CertStore, filename+".json")
certInfo, err := acme.LoadCertInfoJSON(certInfoFilename) useDNSValidation := false //Default to false for HTTP TLS certificates
if err != nil { certInfo, err := acme.LoadCertInfoJSON(certInfoFilename) //Note: Not all certs have info json
SystemWideLogger.PrintAndLog("Could not Load CertInfoJson", certInfoFilename, err) if err == nil {
useDNSValidation = certInfo.UseDNS
} }
thisCertInfo := CertInfo{ thisCertInfo := CertInfo{
@ -94,7 +95,7 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
LastModifiedDate: modifiedTime, LastModifiedDate: modifiedTime,
ExpireDate: certExpireTime, ExpireDate: certExpireTime,
RemainingDays: expiredIn, RemainingDays: expiredIn,
UseDNS: certInfo.UseDNS, UseDNS: useDNSValidation,
} }
results = append(results, &thisCertInfo) results = append(results, &thisCertInfo)

View File

@ -155,7 +155,7 @@ func GetDefaultRootConfig() (*dynamicproxy.ProxyEndpoint, error) {
*/ */
func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) { func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) {
includeSysDBRaw, err := utils.GetPara(r, "includeDB") includeSysDBRaw, _ := utils.GetPara(r, "includeDB")
includeSysDB := false includeSysDB := false
if includeSysDBRaw == "true" { if includeSysDBRaw == "true" {
//Include the system database in backup snapshot //Include the system database in backup snapshot
@ -177,7 +177,7 @@ func ExportConfigAsZip(w http.ResponseWriter, r *http.Request) {
defer zipWriter.Close() defer zipWriter.Close()
// Walk through the folder and add files to the zip // 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 { if err != nil {
return err return err
} }