(tls_config: &TlsConfig, alt_names: Vec<String>)
| 107 | } |
| 108 | |
| 109 | async 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 | |
| 138 | async fn gen_debug_certs( |
| 139 | config: &Config, |
no test coverage detected