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

Function load_extra_cas

nodedb/src/control/cluster/tls.rs:210–229  ·  view source on GitHub ↗

Load every PEM-encoded CA certificate from `tls_dir/ca.d/*.crt`, sorted by filename for deterministic output. Missing directory is treated as "no overlap CAs" and returns an empty vec.

(tls_dir: &Path)

Source from the content-addressed store, hash-verified

208/// sorted by filename for deterministic output. Missing directory is
209/// treated as "no overlap CAs" and returns an empty vec.
210fn load_extra_cas(tls_dir: &Path) -> crate::Result<Vec<CertificateDer<'static>>> {
211 let dir = tls_dir.join(CA_TRUST_DIR);
212 if !dir.exists() {
213 return Ok(Vec::new());
214 }
215 let mut entries: Vec<PathBuf> = fs::read_dir(&dir)
216 .map_err(|e| crate::Error::Config {
217 detail: format!("read ca.d {}: {e}", dir.display()),
218 })?
219 .filter_map(|r| r.ok())
220 .map(|e| e.path())
221 .filter(|p| p.extension().and_then(|s| s.to_str()) == Some("crt"))
222 .collect();
223 entries.sort();
224 let mut out = Vec::with_capacity(entries.len());
225 for p in entries {
226 out.push(read_single_cert(&p)?);
227 }
228 Ok(out)
229}
230
231/// Write a PEM-encoded CA cert into `tls_dir/ca.d/<fp_hex>.crt`.
232/// Called by the production applier when a `CaTrustChange { add: ... }`

Callers 3

load_from_pathsFunction · 0.85
load_from_data_dirFunction · 0.85
bootstrap_credentialsFunction · 0.85

Calls 8

read_single_certFunction · 0.85
joinMethod · 0.80
collectMethod · 0.80
existsMethod · 0.45
okMethod · 0.45
pathMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected