Skip to content

Updating letsencrypt certs #104

Answered by SajjadPourali
ejheil asked this question in Q&A
Apr 24, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hello, it automatically renews the certificates when they expire in 7 days or less.

pub fn renew_needed(&self) -> bool {
for certificate in self.certificate_chain.iter() {
let Ok((_, cert)) = X509Certificate::from_der(certificate.as_ref()) else {
return true;
};
if cert.is_ca() {
continue;
}
if cert
.validity()
.time_to_expiration()
.and_then(|d| {
d.unsigned_abs()
.checked_sub(Duration::from_secs(7 * 24 * 60 * 60))
})
.is_none()
{
return true;
}
}
false
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ejheil
Comment options

@SajjadPourali
Comment options

Answer selected by SajjadPourali
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants