Auto renew given certificate Checks if the certificate is about to expire and renews it if necessary.
(
&self,
cert_pem: &str,
key_pem: &str,
expires_in: Duration,
)
| 192 | /// |
| 193 | /// Checks if the certificate is about to expire and renews it if necessary. |
| 194 | pub async fn renew_cert_if_needed( |
| 195 | &self, |
| 196 | cert_pem: &str, |
| 197 | key_pem: &str, |
| 198 | expires_in: Duration, |
| 199 | ) -> Result<Option<String>> { |
| 200 | if !need_renew(cert_pem, expires_in)? { |
| 201 | return Ok(None); |
| 202 | } |
| 203 | let cert = self |
| 204 | .renew_cert(cert_pem, key_pem) |
| 205 | .await |
| 206 | .context("failed to renew cert")?; |
| 207 | Ok(Some(cert)) |
| 208 | } |
| 209 | |
| 210 | /// Renew given certificate |
| 211 | pub async fn renew_cert(&self, cert_pem: &str, key_pem: &str) -> Result<String> { |
no test coverage detected