1#[cfg(feature = "tls")]
6use std::path::PathBuf;
7
8#[cfg(feature = "tls")]
10#[derive(Clone, Debug)]
11pub struct TlsConfig {
12 pub cert_path: PathBuf,
14 pub key_path: PathBuf,
16}
17
18#[cfg(feature = "tls")]
19impl TlsConfig {
20 pub fn new(cert_path: impl Into<PathBuf>, key_path: impl Into<PathBuf>) -> Self {
22 Self {
23 cert_path: cert_path.into(),
24 key_path: key_path.into(),
25 }
26 }
27
28 pub async fn build_rustls_config(
30 &self,
31 ) -> Result<axum_server::tls_rustls::RustlsConfig, std::io::Error> {
32 axum_server::tls_rustls::RustlsConfig::from_pem_file(&self.cert_path, &self.key_path).await
33 }
34}