|
@@ -11,6 +11,7 @@ import (
|
|
"os"
|
|
"os"
|
|
"path/filepath"
|
|
"path/filepath"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "time"
|
|
|
|
|
|
"imuslab.com/zoraxy/mod/utils"
|
|
"imuslab.com/zoraxy/mod/utils"
|
|
)
|
|
)
|
|
@@ -45,6 +46,7 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
|
|
Domain string
|
|
Domain string
|
|
LastModifiedDate string
|
|
LastModifiedDate string
|
|
ExpireDate string
|
|
ExpireDate string
|
|
|
|
+ RemainingDays int
|
|
}
|
|
}
|
|
|
|
|
|
results := []*CertInfo{}
|
|
results := []*CertInfo{}
|
|
@@ -61,6 +63,7 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
certExpireTime := "Unknown"
|
|
certExpireTime := "Unknown"
|
|
certBtyes, err := os.ReadFile(certFilepath)
|
|
certBtyes, err := os.ReadFile(certFilepath)
|
|
|
|
+ expiredIn := 0
|
|
if err != nil {
|
|
if err != nil {
|
|
//Unable to load this file
|
|
//Unable to load this file
|
|
continue
|
|
continue
|
|
@@ -71,6 +74,11 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
|
|
cert, err := x509.ParseCertificate(block.Bytes)
|
|
cert, err := x509.ParseCertificate(block.Bytes)
|
|
if err == nil {
|
|
if err == nil {
|
|
certExpireTime = cert.NotAfter.Format("2006-01-02 15:04:05")
|
|
certExpireTime = cert.NotAfter.Format("2006-01-02 15:04:05")
|
|
|
|
+
|
|
|
|
+ duration := cert.NotAfter.Sub(time.Now())
|
|
|
|
+
|
|
|
|
+ // Convert the duration to days
|
|
|
|
+ expiredIn = int(duration.Hours() / 24)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -79,6 +87,7 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
|
|
Domain: filename,
|
|
Domain: filename,
|
|
LastModifiedDate: modifiedTime,
|
|
LastModifiedDate: modifiedTime,
|
|
ExpireDate: certExpireTime,
|
|
ExpireDate: certExpireTime,
|
|
|
|
+ RemainingDays: expiredIn,
|
|
}
|
|
}
|
|
|
|
|
|
results = append(results, &thisCertInfo)
|
|
results = append(results, &thisCertInfo)
|