@@ -103,53 +103,54 @@ func (cfg *Config) certNeedsRenewal(leaf *x509.Certificate, ari acme.RenewalInfo
103
103
logger = zap .NewNop ()
104
104
}
105
105
106
- // first check ARI: if it says it's time to renew, it's time to renew
107
- // (notice that we don't strictly require an ARI window to also exist; we presume
108
- // that if a time has been selected, a window does or did exist, even if it didn't
109
- // get stored/encoded for some reason - but also: this allows administrators to
110
- // manually or explicitly schedule a renewal time indepedently of ARI which could
111
- // be useful)
112
- selectedTime := ari .SelectedTime
113
-
114
- // if, for some reason a random time in the window hasn't been selected yet, but an ARI
115
- // window does exist, we can always improvise one... even if this is called repeatedly,
116
- // a random time is a random time, whether you generate it once or more :D
117
- // (code borrowed from our acme package)
118
- if selectedTime .IsZero () &&
119
- (! ari .SuggestedWindow .Start .IsZero () && ! ari .SuggestedWindow .End .IsZero ()) {
120
- start , end := ari .SuggestedWindow .Start .Unix ()+ 1 , ari .SuggestedWindow .End .Unix ()
121
- selectedTime = time .Unix (rand .Int63n (end - start )+ start , 0 ).UTC ()
122
- logger .Warn ("no renewal time had been selected with ARI; chose an ephemeral one for now" ,
123
- zap .Time ("ephemeral_selected_time" , selectedTime ))
124
- }
125
-
126
- // if a renewal time has been selected, start with that
127
- if ! selectedTime .IsZero () {
128
- // ARI spec recommends an algorithm that renews after the randomly-selected
129
- // time OR just before it if the next waking time would be after it; this
130
- // cutoff can actually be before the start of the renewal window, but the spec
131
- // author says that's OK: https://github.com/aarongable/draft-acme-ari/issues/71
132
- cutoff := ari .SelectedTime .Add (- cfg .certCache .options .RenewCheckInterval )
133
- if time .Now ().After (cutoff ) {
134
- logger .Info ("certificate needs renewal based on ARI window" ,
135
- zap .Time ("selected_time" , selectedTime ),
136
- zap .Time ("renewal_cutoff" , cutoff ))
137
- return true
106
+ if ! cfg .DisableARI {
107
+ // first check ARI: if it says it's time to renew, it's time to renew
108
+ // (notice that we don't strictly require an ARI window to also exist; we presume
109
+ // that if a time has been selected, a window does or did exist, even if it didn't
110
+ // get stored/encoded for some reason - but also: this allows administrators to
111
+ // manually or explicitly schedule a renewal time indepedently of ARI which could
112
+ // be useful)
113
+ selectedTime := ari .SelectedTime
114
+
115
+ // if, for some reason a random time in the window hasn't been selected yet, but an ARI
116
+ // window does exist, we can always improvise one... even if this is called repeatedly,
117
+ // a random time is a random time, whether you generate it once or more :D
118
+ // (code borrowed from our acme package)
119
+ if selectedTime .IsZero () &&
120
+ (! ari .SuggestedWindow .Start .IsZero () && ! ari .SuggestedWindow .End .IsZero ()) {
121
+ start , end := ari .SuggestedWindow .Start .Unix ()+ 1 , ari .SuggestedWindow .End .Unix ()
122
+ selectedTime = time .Unix (rand .Int63n (end - start )+ start , 0 ).UTC ()
123
+ logger .Warn ("no renewal time had been selected with ARI; chose an ephemeral one for now" ,
124
+ zap .Time ("ephemeral_selected_time" , selectedTime ))
138
125
}
139
126
140
- // according to ARI, we are not ready to renew; however, we do not rely solely on
141
- // ARI calculations... what if there is a bug in our implementation, or in the
142
- // server's, or the stored metadata? for redundancy, give credence to the expiration
143
- // date; ignore ARI if we are past a "dangerously close" limit, to avoid any
144
- // possibility of a bug in ARI compromising a site's uptime: we should always always
145
- // always give heed to actual validity period
146
- if currentlyInRenewalWindow (leaf .NotBefore , expiration , 1.0 / 20.0 ) {
147
- logger .Warn ("certificate is in emergency renewal window; superceding ARI" ,
148
- zap .Duration ("remaining" , time .Until (expiration )),
149
- zap .Time ("renewal_cutoff" , cutoff ))
150
- return true
127
+ // if a renewal time has been selected, start with that
128
+ if ! selectedTime .IsZero () {
129
+ // ARI spec recommends an algorithm that renews after the randomly-selected
130
+ // time OR just before it if the next waking time would be after it; this
131
+ // cutoff can actually be before the start of the renewal window, but the spec
132
+ // author says that's OK: https://github.com/aarongable/draft-acme-ari/issues/71
133
+ cutoff := ari .SelectedTime .Add (- cfg .certCache .options .RenewCheckInterval )
134
+ if time .Now ().After (cutoff ) {
135
+ logger .Info ("certificate needs renewal based on ARI window" ,
136
+ zap .Time ("selected_time" , selectedTime ),
137
+ zap .Time ("renewal_cutoff" , cutoff ))
138
+ return true
139
+ }
140
+
141
+ // according to ARI, we are not ready to renew; however, we do not rely solely on
142
+ // ARI calculations... what if there is a bug in our implementation, or in the
143
+ // server's, or the stored metadata? for redundancy, give credence to the expiration
144
+ // date; ignore ARI if we are past a "dangerously close" limit, to avoid any
145
+ // possibility of a bug in ARI compromising a site's uptime: we should always always
146
+ // always give heed to actual validity period
147
+ if currentlyInRenewalWindow (leaf .NotBefore , expiration , 1.0 / 20.0 ) {
148
+ logger .Warn ("certificate is in emergency renewal window; superceding ARI" ,
149
+ zap .Duration ("remaining" , time .Until (expiration )),
150
+ zap .Time ("renewal_cutoff" , cutoff ))
151
+ return true
152
+ }
151
153
}
152
-
153
154
}
154
155
155
156
// the normal check, in the absence of ARI, is to determine if we're near enough (or past)
0 commit comments