(cert_pem: &str, expires_in: Duration)
| 564 | } |
| 565 | |
| 566 | fn need_renew(cert_pem: &str, expires_in: Duration) -> Result<bool> { |
| 567 | let pem = read_pem(cert_pem)?; |
| 568 | let cert = pem.parse_x509().context("Invalid x509 certificate")?; |
| 569 | let not_after = cert.validity().not_after.to_datetime(); |
| 570 | let now = time::OffsetDateTime::now_utc(); |
| 571 | debug!("will expire in {}", not_after - now); |
| 572 | |
| 573 | Ok(not_after < now + expires_in) |
| 574 | } |
| 575 | |
| 576 | pub(crate) fn read_pem(cert_pem: &str) -> Result<Pem> { |
| 577 | Pem::iter_from_buffer(cert_pem.as_bytes()) |
no test coverage detected