feat: set renewal interval of certificates #343

This commit is contained in:
Jacky 2024-04-30 10:26:02 +08:00
parent 4c7e037b76
commit e77d37bbaa
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
5 changed files with 38 additions and 25 deletions

View file

@ -4,6 +4,7 @@ import (
"github.com/0xJacky/Nginx-UI/internal/logger"
"github.com/0xJacky/Nginx-UI/internal/notification"
"github.com/0xJacky/Nginx-UI/model"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/pkg/errors"
"runtime"
"strings"
@ -59,8 +60,8 @@ func renew(certModel *model.Cert) {
notification.Error("Renew Certificate Error", strings.Join(certModel.Domains, ", "))
return
}
if time.Now().Sub(cert.NotBefore).Hours()/24 < 7 {
// not between 1 week, ignore this certificate
if int(time.Now().Sub(cert.NotBefore).Hours()/24) < settings.ServerSettings.CertRenewalInterval {
// not after settings.ServerSettings.CertRenewalInterval, ignore
return
}