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

Function update_certs

kms/src/onboard_service.rs:335–361  ·  view source on GitHub ↗
(cfg: &KmsConfig)

Source from the content-addressed store, hash-verified

333}
334
335pub(crate) async fn update_certs(cfg: &KmsConfig) -> Result<()> {
336 // Read existing keys
337 let tmp_ca_key = KeyPair::from_pem(&fs::read_to_string(cfg.tmp_ca_key())?)?;
338 let ca_key = KeyPair::from_pem(&fs::read_to_string(cfg.root_ca_key())?)?;
339 let rpc_key = KeyPair::from_pem(&fs::read_to_string(cfg.rpc_key())?)?;
340
341 // Read k256 key
342 let k256_key_bytes = fs::read(cfg.k256_key())?;
343 let k256_key = SigningKey::from_slice(&k256_key_bytes)?;
344
345 let domain = if cfg.onboard.auto_bootstrap_domain.is_empty() {
346 fs::read_to_string(cfg.rpc_domain())?
347 } else {
348 cfg.onboard.auto_bootstrap_domain.clone()
349 };
350 let domain = domain.trim();
351
352 // Regenerate certificates using existing keys
353 let keys = Keys::from_keys(tmp_ca_key, ca_key, rpc_key, k256_key, domain)
354 .await
355 .context("Failed to regenerate certificates")?;
356
357 // Write the new certificates to files
358 keys.store_certs(cfg)?;
359
360 Ok(())
361}
362
363pub(crate) async fn bootstrap_keys(cfg: &KmsConfig) -> Result<()> {
364 ensure_self_kms_allowed(cfg)

Callers 1

mainFunction · 0.85

Calls 8

tmp_ca_keyMethod · 0.80
root_ca_keyMethod · 0.80
rpc_keyMethod · 0.80
k256_keyMethod · 0.80
rpc_domainMethod · 0.80
cloneMethod · 0.80
store_certsMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected