MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read_single_cert

Function read_single_cert

nodedb/src/control/cluster/tls.rs:379–394  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

377}
378
379fn read_single_cert(path: &Path) -> crate::Result<CertificateDer<'static>> {
380 let bytes = fs::read(path).map_err(|e| crate::Error::Config {
381 detail: format!("read cert {}: {e}", path.display()),
382 })?;
383 let mut reader = BufReader::new(&bytes[..]);
384 let mut iter = rustls_pemfile::certs(&mut reader);
385 match iter.next() {
386 Some(Ok(cert)) => Ok(cert),
387 Some(Err(e)) => Err(crate::Error::Config {
388 detail: format!("parse cert {}: {e}", path.display()),
389 }),
390 None => Err(crate::Error::Config {
391 detail: format!("cert file {} contains no PEM certificates", path.display()),
392 }),
393 }
394}
395
396fn read_private_key(path: &Path) -> crate::Result<PrivateKeyDer<'static>> {
397 ensure_secret_file_perms(path)?;

Callers 3

load_from_pathsFunction · 0.85
load_from_data_dirFunction · 0.85
load_extra_casFunction · 0.85

Calls 2

readFunction · 0.50
nextMethod · 0.45

Tested by

no test coverage detected