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])
| 232 | /// Called by the production applier when a `CaTrustChange { add: ... }` |
| 233 | /// entry commits. |
| 234 | pub 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 |
no test coverage detected