|
@ -105,7 +105,7 @@ impl Certificate { |
|
|
|
|
|
|
|
|
fn is_expiring(&self, cert: &X509Certificate) -> Result<bool, Error> {
|
|
|
fn is_expiring(&self, cert: &X509Certificate) -> Result<bool, Error> {
|
|
|
let expires_in = cert.expires_in()?;
|
|
|
let expires_in = cert.expires_in()?;
|
|
|
self.debug(&format!("expires in {} days", expires_in.as_secs() / 86400));
|
|
|
|
|
|
|
|
|
self.debug(&format!("Certificate expires in {} days", expires_in.as_secs() / 86400));
|
|
|
// TODO: allow a custom duration (using time-parse ?)
|
|
|
// TODO: allow a custom duration (using time-parse ?)
|
|
|
// 1814400 is 3 weeks (3 * 7 * 24 * 60 * 60)
|
|
|
// 1814400 is 3 weeks (3 * 7 * 24 * 60 * 60)
|
|
|
let renewal_time = Duration::new(1_814_400, 0);
|
|
|
let renewal_time = Duration::new(1_814_400, 0);
|
|
@ -134,7 +134,17 @@ impl Certificate { |
|
|
has_miss
|
|
|
has_miss
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Return a comma-separated list of the domains this certificate is valid for.
|
|
|
|
|
|
pub fn domain_list(&self) -> String {
|
|
|
|
|
|
self.domains
|
|
|
|
|
|
.iter()
|
|
|
|
|
|
.map(|domain| &*domain.dns)
|
|
|
|
|
|
.collect::<Vec<&str>>()
|
|
|
|
|
|
.join(",")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn should_renew(&self) -> Result<bool, Error> {
|
|
|
pub fn should_renew(&self) -> Result<bool, Error> {
|
|
|
|
|
|
self.debug(&format!("Checking for renewal (domains: {})", self.domain_list()));
|
|
|
if !certificate_files_exists(&self) {
|
|
|
if !certificate_files_exists(&self) {
|
|
|
self.debug("certificate does not exist: requesting one");
|
|
|
self.debug("certificate does not exist: requesting one");
|
|
|
return Ok(true);
|
|
|
return Ok(true);
|
|
@ -145,9 +155,9 @@ impl Certificate { |
|
|
let renew = renew || self.is_expiring(&cert)?;
|
|
|
let renew = renew || self.is_expiring(&cert)?;
|
|
|
|
|
|
|
|
|
if renew {
|
|
|
if renew {
|
|
|
self.debug("The certificate will be renewed now.");
|
|
|
|
|
|
|
|
|
self.debug("The certificate will be renewed now");
|
|
|
} else {
|
|
|
} else {
|
|
|
self.debug("The certificate will not be renewed now.");
|
|
|
|
|
|
|
|
|
self.debug("The certificate will not be renewed now");
|
|
|
}
|
|
|
}
|
|
|
Ok(renew)
|
|
|
Ok(renew)
|
|
|
}
|
|
|
}
|
|
|