MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / write_ca_files

Function write_ca_files

crates/openshell-supervisor-network/src/l7/tls.rs:241–262  ·  view source on GitHub ↗

Write CA certificate files for the sandbox trust store. Writes: 1. Standalone CA cert PEM (for `NODE_EXTRA_CA_CERTS` which is additive) 2. Combined bundle: system CAs + sandbox CA (for `SSL_CERT_FILE` which replaces default) `system_ca_bundle` is the pre-read PEM contents of the system CA bundle (from [`read_system_ca_bundle`]). Pass the same string to [`build_upstream_client_config`] to avoid r

(
    ca: &SandboxCa,
    output_dir: &Path,
    system_ca_bundle: &str,
)

Source from the content-addressed store, hash-verified

239///
240/// Returns `(ca_cert_path, combined_bundle_path)`.
241pub fn write_ca_files(
242 ca: &SandboxCa,
243 output_dir: &Path,
244 system_ca_bundle: &str,
245) -> Result<(PathBuf, PathBuf)> {
246 std::fs::create_dir_all(output_dir).into_diagnostic()?;
247
248 let ca_cert_path = output_dir.join("openshell-ca.pem");
249 std::fs::write(&ca_cert_path, ca.cert_pem()).into_diagnostic()?;
250
251 // Combine system CAs with our sandbox CA
252 let mut combined = system_ca_bundle.to_string();
253 if !combined.is_empty() && !combined.ends_with('\n') {
254 combined.push('\n');
255 }
256 combined.push_str(ca.cert_pem());
257
258 let combined_path = output_dir.join("ca-bundle.pem");
259 std::fs::write(&combined_path, &combined).into_diagnostic()?;
260
261 Ok((ca_cert_path, combined_path))
262}
263
264/// Load PEM-encoded certificates from a string into a root certificate store.
265///

Callers 2

run_networkingFunction · 0.85

Calls 3

cert_pemMethod · 0.80
pushMethod · 0.80
is_emptyMethod · 0.45

Tested by 1