MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / get_root_certs

Function get_root_certs

chirpstack/src/helpers/tls.rs:9–25  ·  view source on GitHub ↗

Return root certificates, optionally with the provided ca_file appended.

(ca_file: Option<String>)

Source from the content-addressed store, hash-verified

7
8// Return root certificates, optionally with the provided ca_file appended.
9pub fn get_root_certs(ca_file: Option<String>) -> Result<rustls::RootCertStore> {
10 let mut roots = rustls::RootCertStore::empty();
11 for cert in rustls_native_certs::load_native_certs().certs {
12 roots.add(cert)?;
13 }
14
15 if let Some(ca_file) = &ca_file {
16 let f = File::open(ca_file).context("Open CA certificate")?;
17 let mut reader = BufReader::new(f);
18 let certs = rustls_pemfile::certs(&mut reader);
19 for cert in certs.flatten() {
20 roots.add(cert)?;
21 }
22 }
23
24 Ok(roots)
25}
26
27pub async fn load_cert(cert_file: &str) -> Result<Vec<CertificateDer<'static>>> {
28 let cert_s = fs::read_to_string(cert_file)

Callers 5

newMethod · 0.85
pg_establish_connectionFunction · 0.85
pg_establish_connectionFunction · 0.85
setupFunction · 0.85
newMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected