Skip to content

Commit

Permalink
enhance: limit cert renewal interval between 7 to 21 days
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Apr 30, 2024
1 parent 49b41d6 commit e3876cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/cert/auto_cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func renew(certModel *model.Cert) {
notification.Error("Renew Certificate Error", strings.Join(certModel.Domains, ", "))
return
}
if int(time.Now().Sub(cert.NotBefore).Hours()/24) < settings.ServerSettings.CertRenewalInterval {
if int(time.Now().Sub(cert.NotBefore).Hours()/24) < settings.ServerSettings.GetCertRenewalInterval() {
// not after settings.ServerSettings.CertRenewalInterval, ignore
return
}
Expand Down
10 changes: 10 additions & 0 deletions settings/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ func (s *Server) GetCADir() string {
return lego.LEDirectoryProduction
}

func (s *Server) GetCertRenewalInterval() int {
if s.CertRenewalInterval < 7 {
return 7
}
if s.CertRenewalInterval > 21 {
return 21
}
return s.CertRenewalInterval
}

var ServerSettings = Server{
HttpHost: "0.0.0.0",
HttpPort: "9000",
Expand Down

0 comments on commit e3876cf

Please sign in to comment.