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

Method new

kms/src/main_service.rs:98–131  ·  view source on GitHub ↗
(config: KmsConfig)

Source from the content-addressed store, hash-verified

96
97impl KmsState {
98 pub fn new(config: KmsConfig) -> Result<Self> {
99 let root_ca = CaCert::load(config.root_ca_cert(), config.root_ca_key())
100 .context("Failed to load root CA certificate")?;
101 let key_bytes = fs::read(config.k256_key()).context("Failed to read ECDSA root key")?;
102 let k256_key =
103 SigningKey::from_slice(&key_bytes).context("Failed to load ECDSA root key")?;
104 let temp_ca_key =
105 fs::read_to_string(config.tmp_ca_key()).context("Faeild to read temp ca key")?;
106 let temp_ca_cert =
107 fs::read_to_string(config.tmp_ca_cert()).context("Faeild to read temp ca cert")?;
108 let verifier = CvmVerifier::new(
109 config.image.cache_dir.display().to_string(),
110 config.image.download_url.clone(),
111 config.image.download_timeout,
112 config.pccs_url.clone(),
113 );
114 if !config.enforce_self_authorization {
115 warn!(
116 "self-authorization is disabled; trusted RPCs will not be gated by KMS self-attestation - do not use in production TEE deployments"
117 );
118 }
119 Ok(Self {
120 inner: Arc::new(KmsStateInner {
121 config,
122 root_ca,
123 k256_key,
124 temp_ca_cert,
125 temp_ca_key,
126 verifier,
127 self_boot_info: OnceCell::new(),
128 metrics: KmsMetrics::default(),
129 }),
130 })
131 }
132
133 pub(crate) fn metrics(&self) -> &KmsMetrics {
134 &self.inner.metrics

Callers

nothing calls this directly

Calls 7

root_ca_certMethod · 0.80
root_ca_keyMethod · 0.80
k256_keyMethod · 0.80
tmp_ca_keyMethod · 0.80
tmp_ca_certMethod · 0.80
displayMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected