Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gateway): handle certificate expiration as well #932

Merged
merged 2 commits into from
May 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions gateway/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,15 +642,22 @@ impl GatewayService {
.unwrap_or_else(|_| panic!("Malformed existing PEM certificate for the gateway."));
let (_, x509_cert) = parse_x509_certificate(pem.contents.as_bytes())
.unwrap_or_else(|_| panic!("Malformed existing X509 certificate for the gateway."));
let diff = x509_cert.validity().not_after.sub(ASN1Time::now()).unwrap();
if diff.whole_days() <= RENEWAL_VALIDITY_THRESHOLD_IN_DAYS {
let diff = x509_cert.validity().not_after.sub(ASN1Time::now());
if diff.is_none()
iulianbarbu marked this conversation as resolved.
Show resolved Hide resolved
|| diff
.expect("to be Some given we checked for None previously")
.whole_days()
<= RENEWAL_VALIDITY_THRESHOLD_IN_DAYS
{
let tls_path = self.state_location.join("ssl.pem");
let certs = self.create_certificate(acme, account.credentials()).await;
resolver
.serve_default_der(certs.clone())
.await
.expect("Failed to serve the default certs");
certs.save_pem(&tls_path).unwrap();
certs
.save_pem(&tls_path)
.expect("to save the certificate locally");
}
}

Expand Down