Browse Source

Prevent panic from selecting a random value from an empty range

Fixes #102
pull/104/head
Rodolphe Bréard 1 year ago
parent
commit
0e1e9a818d
  1. 10
      acmed/src/certificate.rs

10
acmed/src/certificate.rs

@ -79,9 +79,13 @@ impl Certificate {
expires_in.as_secs() / 86400, expires_in.as_secs() / 86400,
self.renew_delay.as_secs() / 86400, self.renew_delay.as_secs() / 86400,
)); ));
Ok(expires_in
.saturating_sub(self.renew_delay)
.saturating_sub(thread_rng().gen_range(Duration::ZERO..self.random_early_renew)))
let expires_in = expires_in.saturating_sub(self.renew_delay);
let expires_in = if !self.random_early_renew.is_zero() {
expires_in.saturating_sub(thread_rng().gen_range(Duration::ZERO..self.random_early_renew))
} else {
expires_in
};
Ok(expires_in)
} }
fn has_missing_identifiers(&self, cert: &X509Certificate) -> bool { fn has_missing_identifiers(&self, cert: &X509Certificate) -> bool {

Loading…
Cancel
Save