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

Function write_trusted_ca

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

Write a PEM-encoded CA cert into `tls_dir/ca.d/ .crt`. Called by the production applier when a `CaTrustChange { add: ... }` entry commits.

(tls_dir: &Path, ca_der: &[u8])

Source from the content-addressed store, hash-verified

232/// Called by the production applier when a `CaTrustChange { add: ... }`
233/// entry commits.
234pub fn write_trusted_ca(tls_dir: &Path, ca_der: &[u8]) -> crate::Result<[u8; 32]> {
235 let dir = tls_dir.join(CA_TRUST_DIR);
236 fs::create_dir_all(&dir).map_err(|e| crate::Error::Config {
237 detail: format!("create ca.d dir {}: {e}", dir.display()),
238 })?;
239 let cert = CertificateDer::from(ca_der.to_vec());
240 let fp = nodedb_cluster::ca_fingerprint(&cert);
241 let path = dir.join(format!("{}.crt", nodedb_cluster::ca_fingerprint_hex(&fp)));
242 write_pem_cert(&path, ca_der)?;
243 Ok(fp)
244}
245
246/// Delete the overlap-CA file identified by `fp` from `tls_dir/ca.d/`.
247/// No-op (and returns `Ok(())`) when the file isn't present — applier

Callers 1

apply_ca_trust_changeFunction · 0.85

Calls 4

ca_fingerprintFunction · 0.85
joinMethod · 0.80
write_pem_certFunction · 0.70
to_vecMethod · 0.45

Tested by

no test coverage detected