MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / build_rustls_config

Function build_rustls_config

crates/openshell-cli/src/tls.rs:203–223  ·  view source on GitHub ↗
(materials: &TlsMaterials)

Source from the content-addressed store, hash-verified

201}
202
203pub fn build_rustls_config(materials: &TlsMaterials) -> Result<rustls::ClientConfig> {
204 let mut roots = RootCertStore::empty();
205 let mut ca_cursor = Cursor::new(&materials.ca);
206 let ca_certs = rustls_pemfile::certs(&mut ca_cursor)
207 .collect::<Result<Vec<CertificateDer<'static>>, _>>()
208 .into_diagnostic()?;
209 for cert in ca_certs {
210 roots.add(cert).into_diagnostic()?;
211 }
212
213 let mut cert_cursor = Cursor::new(&materials.cert);
214 let cert_chain = rustls_pemfile::certs(&mut cert_cursor)
215 .collect::<Result<Vec<CertificateDer<'static>>, _>>()
216 .into_diagnostic()?;
217 let key = load_private_key(&materials.key)?;
218
219 rustls::ClientConfig::builder()
220 .with_root_certificates(roots)
221 .with_client_auth_cert(cert_chain, key)
222 .into_diagnostic()
223}
224
225pub fn build_tonic_tls_config(materials: &TlsMaterials) -> ClientTlsConfig {
226 let ca_cert = Certificate::from_pem(materials.ca.clone());

Callers 1

http_health_checkFunction · 0.85

Calls 1

load_private_keyFunction · 0.85

Tested by

no test coverage detected