File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -210,8 +210,15 @@ func (c *Client) GetRenewalInfo(ctx context.Context, leafCert *x509.Certificate)
210210 // https://github.com/aarongable/draft-acme-ari/issues/70
211211 // We add 1 to the start time since we are dealing in seconds for
212212 // simplicity, but the server may provide sub-second timestamps.
213+ // We also try our best with invalid start/end values (see #40).
213214 start , end := ari .SuggestedWindow .Start .Unix ()+ 1 , ari .SuggestedWindow .End .Unix ()
214- ari .SelectedTime = time .Unix (rand .Int63n (end - start )+ start , 0 ).UTC ()
215+ if end > start {
216+ ari .SelectedTime = time .Unix (rand .Int63n (end - start )+ start , 0 ).UTC ()
217+ } else if start > 0 {
218+ ari .SelectedTime = time .Unix (start , 0 ).UTC ()
219+ } else if end > 0 {
220+ ari .SelectedTime = time .Unix (end , 0 ).UTC ()
221+ }
215222
216223 if c .Logger != nil {
217224 c .Logger .LogAttrs (ctx , slog .LevelInfo , "got renewal info" ,
You can’t perform that action at this time.
0 commit comments