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

Function gen_prod_certs

gateway/src/main.rs:109–136  ·  view source on GitHub ↗
(tls_config: &TlsConfig, alt_names: Vec<String>)

Source from the content-addressed store, hash-verified

107}
108
109async fn gen_prod_certs(tls_config: &TlsConfig, alt_names: Vec<String>) -> Result<()> {
110 info!("Using dstack guest agent for certificate generation");
111 let agent_client = dstack_agent().context("Failed to create dstack client")?;
112
113 let response = agent_client
114 .get_tls_key(GetTlsKeyArgs {
115 subject: "dstack-gateway".to_string(),
116 alt_names,
117 usage_ra_tls: true,
118 usage_server_auth: true,
119 usage_client_auth: true,
120 not_before: None,
121 not_after: None,
122 with_app_info: true,
123 })
124 .await?;
125
126 let ca_cert = response
127 .certificate_chain
128 .last()
129 .context("Empty certificate chain")?
130 .to_string();
131 let certs = response.certificate_chain.join("\n");
132 write_cert(&tls_config.mutual.ca_certs, &ca_cert)?;
133 write_cert(&tls_config.certs, &certs)?;
134 write_cert(&tls_config.key, &response.key)?;
135 Ok(())
136}
137
138async fn gen_debug_certs(
139 config: &Config,

Callers 1

maybe_gen_certsFunction · 0.85

Calls 3

dstack_agentFunction · 0.85
write_certFunction · 0.85
get_tls_keyMethod · 0.45

Tested by

no test coverage detected