Parse PEM cert bytes into a `RootCertStore`.
(cert_pem: &[u8])
| 635 | |
| 636 | /// Parse PEM cert bytes into a `RootCertStore`. |
| 637 | pub fn build_tls_root(cert_pem: &[u8]) -> RootCertStore { |
| 638 | let mut roots = RootCertStore::empty(); |
| 639 | let mut cursor = std::io::Cursor::new(cert_pem); |
| 640 | let parsed = certs(&mut cursor) |
| 641 | .collect::<Result<Vec<CertificateDer<'static>>, _>>() |
| 642 | .expect("failed to parse cert pem"); |
| 643 | for cert in parsed { |
| 644 | roots.add(cert).expect("failed to add cert"); |
| 645 | } |
| 646 | roots |
| 647 | } |
| 648 | |
| 649 | /// Build a gRPC client with mTLS (CA + client cert). |
| 650 | pub async fn grpc_client_mtls( |
no outgoing calls
no test coverage detected