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

Function load_certs

crates/openshell-server/src/tls.rs:299–313  ·  view source on GitHub ↗

Load certificates from a PEM file.

(path: &Path)

Source from the content-addressed store, hash-verified

297
298/// Load certificates from a PEM file.
299fn load_certs(path: &Path) -> Result<Vec<CertificateDer<'static>>> {
300 let file =
301 File::open(path).map_err(|e| Error::tls(format!("failed to open cert file: {e}")))?;
302 let mut reader = BufReader::new(file);
303
304 let certs: Vec<_> = rustls_pemfile::certs(&mut reader)
305 .collect::<std::result::Result<Vec<_>, _>>()
306 .map_err(|e| Error::tls(format!("failed to parse certificates: {e}")))?;
307
308 if certs.is_empty() {
309 return Err(Error::tls("no certificates found in file"));
310 }
311
312 Ok(certs)
313}
314
315/// Load a private key from a PEM file.
316fn load_key(path: &Path) -> Result<PrivateKeyDer<'static>> {

Callers 4

build_server_configFunction · 0.85
build_test_client_configFunction · 0.85

Calls 1

is_emptyMethod · 0.45