| 370 | } |
| 371 | |
| 372 | fn build_test_client_config(ca_path: &Path) -> Arc<rustls::ClientConfig> { |
| 373 | let ca_certs = load_certs(ca_path).expect("failed to load CA certs"); |
| 374 | let mut root_store = rustls::RootCertStore::empty(); |
| 375 | for cert in ca_certs { |
| 376 | root_store |
| 377 | .add(cert) |
| 378 | .expect("failed to add CA to root store"); |
| 379 | } |
| 380 | Arc::new( |
| 381 | rustls::ClientConfig::builder() |
| 382 | .with_root_certificates(root_store) |
| 383 | .with_no_client_auth(), |
| 384 | ) |
| 385 | } |
| 386 | |
| 387 | /// Extract the DER-encoded server certificate from a TLS session. |
| 388 | fn peer_cert_der(tls: &tokio_rustls::client::TlsStream<TcpStream>) -> Vec<u8> { |