pub struct Tls {
pub enabled: bool,
pub certificate: PathBuf,
pub private_key: PathBuf,
}Available on crate features
openssl or rustls-0_23 only.Expand description
TLS (HTTPS) configuration.
Fields§
§enabled: boolTrue if accepting TLS connections should be enabled.
certificate: PathBufPath to certificate .pem file.
private_key: PathBufPath to private key .pem file.
Implementations§
Source§impl Tls
impl Tls
Sourcepub fn get_ssl_acceptor_builder(&self) -> Result<SslAcceptorBuilder, Error>
Available on crate feature openssl only.
pub fn get_ssl_acceptor_builder(&self) -> Result<SslAcceptorBuilder, Error>
openssl only.Returns an SslAcceptorBuilder with the configured settings.
The result is often used with actix_web::HttpServer::bind_openssl().
§Example
use std::io;
use actix_settings::{ApplySettings as _, Settings};
use actix_web::{get, web, App, HttpServer, Responder};
#[actix_web::main]
async fn main() -> io::Result<()> {
let settings = Settings::from_default_template();
HttpServer::new(|| {
App::new().route("/", web::to(|| async { "Hello, World!" }))
})
.try_apply_settings(&settings)?
.bind(("127.0.0.1", 8080))?
.bind_openssl(("127.0.0.1", 8443), settings.actix.tls.get_ssl_acceptor_builder()?)?
.run()
.await
}Sourcepub fn get_rustls_0_23_server_config(
&self,
) -> Result<Rustls023ServerConfig, Error>
Available on crate feature rustls-0_23 only.
pub fn get_rustls_0_23_server_config( &self, ) -> Result<Rustls023ServerConfig, Error>
rustls-0_23 only.Returns a Rustls023ServerConfig with the configured settings.
The result is often used with actix_web::HttpServer::bind_rustls_0_23().
§Example
use std::io;
use actix_settings::{ApplySettings as _, Settings};
use actix_web::{web, App, HttpServer};
#[actix_web::main]
async fn main() -> io::Result<()> {
let settings = Settings::from_default_template();
HttpServer::new(|| {
App::new().route("/", web::to(|| async { "Hello, World!" }))
})
.try_apply_settings(&settings)?
.bind_rustls_0_23(
("127.0.0.1", 8443),
settings.actix.tls.get_rustls_0_23_server_config()?,
)?
.run()
.await
}Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tls
impl<'de> Deserialize<'de> for Tls
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Tls
impl StructuralPartialEq for Tls
Auto Trait Implementations§
impl Freeze for Tls
impl RefUnwindSafe for Tls
impl Send for Tls
impl Sync for Tls
impl Unpin for Tls
impl UnsafeUnpin for Tls
impl UnwindSafe for Tls
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.