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

Method from_keys

kms/src/onboard_service.rs:194–244  ·  view source on GitHub ↗
(
        tmp_ca_key: KeyPair,
        ca_key: KeyPair,
        rpc_key: KeyPair,
        k256_key: SigningKey,
        domain: &str,
    )

Source from the content-addressed store, hash-verified

192 }
193
194 async fn from_keys(
195 tmp_ca_key: KeyPair,
196 ca_key: KeyPair,
197 rpc_key: KeyPair,
198 k256_key: SigningKey,
199 domain: &str,
200 ) -> Result<Self> {
201 let tmp_ca_cert = CertRequest::builder()
202 .org_name("Dstack")
203 .subject("Dstack Client Temp CA")
204 .ca_level(0)
205 .key(&tmp_ca_key)
206 .build()
207 .self_signed()?;
208
209 // Create self-signed KMS cert
210 let ca_cert = CertRequest::builder()
211 .org_name("Dstack")
212 .subject("Dstack KMS CA")
213 .ca_level(1)
214 .key(&ca_key)
215 .build()
216 .self_signed()?;
217 let pubkey = rpc_key.public_key_der();
218 let report_data = QuoteContentType::RaTlsCert.to_report_data(&pubkey);
219 let response = app_attest(report_data.to_vec())
220 .await
221 .context("Failed to get quote")?;
222 let attestation = VersionedAttestation::from_bytes(&response.attestation)
223 .context("Invalid attestation")?;
224
225 // Sign WWW server cert with KMS cert
226 let rpc_cert = CertRequest::builder()
227 .subject(domain)
228 .alt_names(&[domain.to_string()])
229 .special_usage("kms:rpc")
230 .maybe_attestation(Some(&attestation))
231 .key(&rpc_key)
232 .build()
233 .signed_by(&ca_cert, &ca_key)?;
234 Ok(Keys {
235 k256_key,
236 tmp_ca_key,
237 tmp_ca_cert,
238 ca_key,
239 ca_cert,
240 rpc_key,
241 rpc_cert,
242 rpc_domain: domain.to_string(),
243 })
244 }
245
246 async fn onboard(
247 cfg: &KmsConfig,

Callers

nothing calls this directly

Calls 6

app_attestFunction · 0.85
self_signedMethod · 0.80
to_report_dataMethod · 0.80
to_vecMethod · 0.80
buildMethod · 0.45
signed_byMethod · 0.45

Tested by

no test coverage detected