Skip to content

Commit ccebcfd

Browse files
committed
enhance(auto-cert): update ignore condition
1 parent 69250a6 commit ccebcfd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.devcontainer/pebble-test/config/pebble-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"shortlived": {
2222
"description": "A short-lived cert profile, without actual enforcement",
23-
"validityPeriod": 518400
23+
"validityPeriod": 7776000
2424
}
2525
}
2626
}

internal/cert/auto_cert.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,17 @@ func autoCert(certModel *model.Cert) {
6161
notification.Error("Renew Certificate Error", strings.Join(certModel.Domains, ", "), nil)
6262
return
6363
}
64-
if int(time.Now().Sub(certInfo.NotBefore).Hours()/24) < settings.CertSettings.GetCertRenewalInterval() {
65-
// not after settings.ServerSettings.RenewalInterval, ignore
64+
65+
// Calculate certificate age (days since NotBefore)
66+
certAge := int(time.Since(certInfo.NotBefore).Hours() / 24)
67+
// Calculate days until expiration
68+
daysUntilExpiration := int(time.Until(certInfo.NotAfter).Hours() / 24)
69+
70+
// Skip renewal only if:
71+
// 1. Certificate age is less than renewal interval AND
72+
// 2. Certificate has more than 6 days remaining before expiration
73+
if certAge < settings.CertSettings.GetCertRenewalInterval() && daysUntilExpiration > 6 {
74+
// Certificate is too young and not expiring soon, ignore
6675
return
6776
}
6877

0 commit comments

Comments
 (0)