MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / auto_renew

Method auto_renew

certbot/src/acme_client.rs:222–255  ·  view source on GitHub ↗

Auto renew given certificate

(
        &self,
        live_cert_pem_path: impl AsRef<Path>,
        live_key_pem_path: impl AsRef<Path>,
        backup_dir: impl AsRef<Path>,
        expires_in: Duration,
        force: bool,
   

Source from the content-addressed store, hash-verified

220
221 /// Auto renew given certificate
222 pub async fn auto_renew(
223 &self,
224 live_cert_pem_path: impl AsRef<Path>,
225 live_key_pem_path: impl AsRef<Path>,
226 backup_dir: impl AsRef<Path>,
227 expires_in: Duration,
228 force: bool,
229 ) -> Result<bool> {
230 let live_cert_pem = fs::read_to_string(live_cert_pem_path.as_ref())?;
231 let live_key_pem = fs::read_to_string(live_key_pem_path.as_ref())?;
232 let new_cert = if force {
233 self.renew_cert(&live_cert_pem, &live_key_pem).await?
234 } else {
235 let Some(new_cert) = self
236 .renew_cert_if_needed(&live_cert_pem, &live_key_pem, expires_in)
237 .await?
238 else {
239 return Ok(false);
240 };
241 new_cert
242 };
243 self.store_cert(
244 live_cert_pem_path.as_ref(),
245 live_key_pem_path.as_ref(),
246 &new_cert,
247 &live_key_pem,
248 backup_dir.as_ref(),
249 )?;
250 info!(
251 "renewed certificate for {}",
252 live_cert_pem_path.as_ref().display()
253 );
254 Ok(true)
255 }
256
257 fn store_cert(
258 &self,

Callers 1

renew_innerMethod · 0.80

Calls 4

renew_cert_if_neededMethod · 0.80
store_certMethod · 0.80
as_refMethod · 0.45
renew_certMethod · 0.45

Tested by

no test coverage detected