pub struct TlsConfig {
pub cert: PathBuf,
pub key: PathBuf,
pub https_redirection_config: RedirectionConfig,
/* private fields */
}Expand description
Represents TLS (Transport Layer Security) configuration options
Fields§
§cert: PathBufPath to a certificate
key: PathBufPath to a private key
https_redirection_config: RedirectionConfigHTTPS redirection configuration options
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn from_pem(path: impl AsRef<Path>) -> TlsConfig
pub fn from_pem(path: impl AsRef<Path>) -> TlsConfig
Creates a configuration by loading cert and key files with default names from a specified folder
Sourcepub fn from_pem_files(cert_file_path: &str, key_file_path: &str) -> TlsConfig
pub fn from_pem_files(cert_file_path: &str, key_file_path: &str) -> TlsConfig
Creates a configuration by specifying a path to cert and key files specifically
Sourcepub fn set_pem(self, path: impl AsRef<Path>) -> TlsConfig
pub fn set_pem(self, path: impl AsRef<Path>) -> TlsConfig
Sets the cert and key files with default names from the specified folder
Sourcepub fn with_cert_path(self, path: impl AsRef<Path>) -> TlsConfig
pub fn with_cert_path(self, path: impl AsRef<Path>) -> TlsConfig
Configure the path to the certificate
Sourcepub fn with_key_path(self, path: impl AsRef<Path>) -> TlsConfig
pub fn with_key_path(self, path: impl AsRef<Path>) -> TlsConfig
Configure the path to the private key
Sourcepub fn with_optional_client_auth(self, path: impl AsRef<Path>) -> TlsConfig
pub fn with_optional_client_auth(self, path: impl AsRef<Path>) -> TlsConfig
Configures the trust anchor for optional TLS client authentication.
Default: None
Sourcepub fn with_required_client_auth(self, path: impl AsRef<Path>) -> TlsConfig
pub fn with_required_client_auth(self, path: impl AsRef<Path>) -> TlsConfig
Configures the trust anchor for required TLS client authentication.
Default: None
Sourcepub fn with_https_redirection(self) -> TlsConfig
pub fn with_https_redirection(self) -> TlsConfig
Configures web server to redirect HTTP requests to HTTPS
Default: false
Sourcepub fn with_http_port(self, port: u16) -> TlsConfig
pub fn with_http_port(self, port: u16) -> TlsConfig
Configures the port for HTTP listener that redirects to HTTPS
Sourcepub fn with_hsts<T>(self, config: T) -> TlsConfig
pub fn with_hsts<T>(self, config: T) -> TlsConfig
Configures HSTS header. If HSTS has already been preconfigured, it does not overwrite it
Default values:
- preload:
true - include_sub_domains:
true - max-age: 30 days (2,592,000 seconds)
- exclude_hosts: empty list
§Example
use volga::tls::TlsConfig;
let tls = TlsConfig::new()
.with_hsts(|hsts| hsts.with_preload(false));Sourcepub fn set_hsts(self, hsts_config: HstsConfig) -> TlsConfig
pub fn set_hsts(self, hsts_config: HstsConfig) -> TlsConfig
Configures HSTS header
Default values:
- preload:
true - include_sub_domains:
true - max-age: 30 days (2,592,000 seconds)
- exclude_hosts: empty list
Sourcepub fn with_hsts_preload(self, preload: bool) -> TlsConfig
pub fn with_hsts_preload(self, preload: bool) -> TlsConfig
Configures whether to set preload in HSTS header
Default value: true
Sourcepub fn with_hsts_sub_domains(self, include: bool) -> TlsConfig
pub fn with_hsts_sub_domains(self, include: bool) -> TlsConfig
Configures whether to set includeSubDomains in the HSTS header
Default: true
Sourcepub fn with_hsts_max_age(self, max_age: Duration) -> TlsConfig
pub fn with_hsts_max_age(self, max_age: Duration) -> TlsConfig
Configures max_age for HSTS header
Default: 30 days (2,592,000 seconds)
Sourcepub fn with_hsts_exclude_hosts(
self,
exclude_hosts: &[&'static str],
) -> TlsConfig
pub fn with_hsts_exclude_hosts( self, exclude_hosts: &[&'static str], ) -> TlsConfig
Configures a list of host names that will not add the HSTS header.
Default: empty list