Create a new TLS acceptor from certificate and key files. When `client_ca_path` is `Some` and `require_client_auth` is `true`, the TLS handshake rejects connections that do not present a valid client certificate signed by the given CA. When `client_ca_path` is `Some` and `require_client_auth` is `false`, client certificates are validated against the CA but not required. Clients may connect witho
(
cert_path: &Path,
key_path: &Path,
client_ca_path: Option<&Path>,
require_client_auth: bool,
)
| 60 | /// |
| 61 | /// Returns an error if the certificate, key, or CA files cannot be read or parsed. |
| 62 | pub fn from_files( |
| 63 | cert_path: &Path, |
| 64 | key_path: &Path, |
| 65 | client_ca_path: Option<&Path>, |
| 66 | require_client_auth: bool, |
| 67 | ) -> Result<Self> { |
| 68 | let config = build_server_config(cert_path, key_path, client_ca_path, require_client_auth)?; |
| 69 | Ok(Self { |
| 70 | config: Arc::new(ArcSwap::from(config)), |
| 71 | cert_path: cert_path.to_path_buf(), |
| 72 | key_path: key_path.to_path_buf(), |
| 73 | client_ca_path: client_ca_path.map(Path::to_path_buf), |
| 74 | require_client_auth, |
| 75 | reload_spawned: Arc::new(AtomicBool::new(false)), |
| 76 | }) |
| 77 | } |
| 78 | |
| 79 | /// Re-read certificates from the same paths used at construction and |
| 80 | /// atomically swap the active config. |
nothing calls this directly
no test coverage detected