Skip to content

Commit

Permalink
fix renew timer firing infinitely
Browse files Browse the repository at this point in the history
This sets the maximum cert renewal request frequency to 6/hours

Improves behavior seen in #25
  • Loading branch information
freswa committed Mar 29, 2023
1 parent 4c6c909 commit f6d5733
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/apns.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (apns *Apns) renewCert(cfg *config.Config) {

// renew certs 30 days before they expire
renewIn := certificateNotValidAfter(certs.Mail).Sub(time.Now().Add(-renewTimeBuffer))
if renewIn.Minutes() < 10 {
renewIn = time.Minute * 10
}
apns.RenewTimer = time.AfterFunc(renewIn, func() { apns.renewCert(cfg) })
log.Warnf("Certificate now valid until %s", certificateNotValidAfter(certs.Mail))
}
Expand Down

0 comments on commit f6d5733

Please sign in to comment.