1
0
mirror of https://github.com/go-acme/lego.git synced 2024-11-21 13:25:48 +02:00

fix(ari): avoid Int63n panic in ShouldRenewAt() (#2246)

This commit is contained in:
Rob Stradling 2024-08-21 23:33:28 +01:00 committed by GitHub
parent c083a989a1
commit 29e98f8a43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,9 +41,11 @@ func (r *RenewalInfoResponse) ShouldRenewAt(now time.Time, willingToSleep time.D
end := r.SuggestedWindow.End.UTC()
// Select a uniform random time within the suggested window.
window := end.Sub(start)
rt := start
if window := end.Sub(start); window > 0 {
randomDuration := time.Duration(rand.Int63n(int64(window)))
rt := start.Add(randomDuration)
rt = rt.Add(randomDuration)
}
// If the selected time is in the past, attempt renewal immediately.
if rt.Before(now) {