TlsConfig

Struct TlsConfig 

Source
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: PathBuf

Path to a certificate

§key: PathBuf

Path to a private key

§https_redirection_config: RedirectionConfig

HTTPS redirection configuration options

Implementations§

Source§

impl TlsConfig

Source

pub fn new() -> TlsConfig

Creates a new, default TLS configuration

Source

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

Source

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

Source

pub fn set_pem(self, path: impl AsRef<Path>) -> TlsConfig

Sets the cert and key files with default names from the specified folder

Source

pub fn set_key(self, key_path: &str) -> TlsConfig

Sets the path to a key file

Source

pub fn set_cert(self, cert_path: &str) -> TlsConfig

Sets the path to a key file

Source

pub fn with_cert_path(self, path: impl AsRef<Path>) -> TlsConfig

Configure the path to the certificate

Source

pub fn with_key_path(self, path: impl AsRef<Path>) -> TlsConfig

Configure the path to the private key

Source

pub fn with_optional_client_auth(self, path: impl AsRef<Path>) -> TlsConfig

Configures the trust anchor for optional TLS client authentication.

Default: None

Source

pub fn with_required_client_auth(self, path: impl AsRef<Path>) -> TlsConfig

Configures the trust anchor for required TLS client authentication.

Default: None

Source

pub fn with_https_redirection(self) -> TlsConfig

Configures web server to redirect HTTP requests to HTTPS

Default: false

Source

pub fn with_http_port(self, port: u16) -> TlsConfig

Configures the port for HTTP listener that redirects to HTTPS

Source

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));
Source

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
Source

pub fn with_hsts_preload(self, preload: bool) -> TlsConfig

Configures whether to set preload in HSTS header

Default value: true

Source

pub fn with_hsts_sub_domains(self, include: bool) -> TlsConfig

Configures whether to set includeSubDomains in the HSTS header

Default: true

Source

pub fn with_hsts_max_age(self, max_age: Duration) -> TlsConfig

Configures max_age for HSTS header

Default: 30 days (2,592,000 seconds)

Source

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

Trait Implementations§

Source§

impl Default for TlsConfig

Source§

fn default() -> TlsConfig

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Inject for T
where T: Default + Send + Sync,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,