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

Function load_from_paths

nodedb/src/control/cluster/tls.rs:161–186  ·  view source on GitHub ↗
(paths: &TlsPaths, tls_dir: &Path)

Source from the content-addressed store, hash-verified

159}
160
161fn load_from_paths(paths: &TlsPaths, tls_dir: &Path) -> crate::Result<TlsCredentials> {
162 let cert = read_single_cert(&paths.cert)?;
163 let key = read_private_key(&paths.key)?;
164 let ca_cert = read_single_cert(&paths.ca)?;
165 let crls = match &paths.crl {
166 Some(p) => read_crls(p)?,
167 None => Vec::new(),
168 };
169 let secret_path = paths
170 .cluster_secret
171 .clone()
172 .unwrap_or_else(|| tls_dir.join(CLUSTER_SECRET_FILE));
173 let cluster_secret = read_cluster_secret(&secret_path)?;
174 let additional_ca_certs = load_extra_cas(tls_dir)?;
175 let spki_pin =
176 nodedb_cluster::transport::spki_pin_from_cert_der(cert.as_ref()).unwrap_or([0u8; 32]);
177 Ok(TlsCredentials {
178 cert,
179 key,
180 ca_cert,
181 additional_ca_certs,
182 crls,
183 cluster_secret,
184 spki_pin,
185 })
186}
187
188fn load_from_data_dir(tls_dir: &Path) -> crate::Result<TlsCredentials> {
189 let cert = read_single_cert(&tls_dir.join(NODE_CERT_FILE))?;

Callers 1

resolve_credentialsFunction · 0.85

Calls 9

read_single_certFunction · 0.85
read_private_keyFunction · 0.85
read_crlsFunction · 0.85
load_extra_casFunction · 0.85
spki_pin_from_cert_derFunction · 0.85
joinMethod · 0.80
read_cluster_secretFunction · 0.70
cloneMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected