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

Method store_cert

certbot/src/acme_client.rs:257–280  ·  view source on GitHub ↗
(
        &self,
        live_cert_pem_path: &Path,
        live_key_pem_path: &Path,
        cert_pem: &str,
        key_pem: &str,
        backup_dir: impl AsRef<Path>,
    )

Source from the content-addressed store, hash-verified

255 }
256
257 fn store_cert(
258 &self,
259 live_cert_pem_path: &Path,
260 live_key_pem_path: &Path,
261 cert_pem: &str,
262 key_pem: &str,
263 backup_dir: impl AsRef<Path>,
264 ) -> Result<()> {
265 use path_absolutize::Absolutize;
266
267 // Put the new cert in {backup_dir}/%Y%m%d_%H%M%S/cert.pem
268 let cert_dir = self.new_cert_dir(backup_dir.as_ref())?;
269 let backup_path = cert_dir.absolutize()?;
270 let cert_path = backup_path.join("cert.pem");
271 let key_path = backup_path.join("key.pem");
272 fs::write(&cert_path, cert_pem)?;
273 fs::write(&key_path, key_pem)?;
274 debug!("stored new cert in {}", cert_dir.display());
275
276 // symlink live_cert_pem_path to the new cert
277 ln_force(cert_path, live_cert_pem_path)?;
278 ln_force(key_path, live_key_pem_path)?;
279 Ok(())
280 }
281
282 /// Auto renew given certificate
283 pub async fn create_cert_if_needed(

Callers 2

auto_renewMethod · 0.80
create_cert_if_neededMethod · 0.80

Calls 3

ln_forceFunction · 0.85
new_cert_dirMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected