TLS
All adapters (except aws_lambda) can be combined with a TLS acceptor.
Rustls
use trillium::Conn;
use trillium_rustls::RustlsAcceptor;
pub fn main() {
env_logger::init();
trillium_smol::config()
.with_acceptor(RustlsAcceptor::from_single_cert(CERT, KEY))
.run(|conn: Conn| async move { conn.ok("ok") });
}
Native TLS
use trillium::Conn;
use trillium_native_tls::NativeTlsAcceptor;
pub fn main() {
env_logger::init();
trillium_smol::config()
.with_acceptor(acceptor)
.run(|conn: Conn| async move { conn.ok("ok") });
}
trillium-native-tls does not currently negotiate ALPN, so HTTP/2 is not available with this
adapter. If you need HTTP/2, use trillium-rustls or trillium-openssl.
OpenSSL
Backed by async-openssl and the
openssl crate. Use this when you need OpenSSL specifically
(e.g. FIPS-validated builds, organization-mandated cryptography library) and still want HTTP/2.
Requires a system OpenSSL install at build time, or enable the vendored cargo feature to compile
OpenSSL from source.
use trillium::Conn;
use trillium_openssl::OpenSslAcceptor;
pub fn main() {
env_logger::init();
trillium_smol::config()
.with_acceptor(OpenSslAcceptor::from_single_cert(CERT, KEY))
.run(|conn: Conn| async move { conn.ok("ok") });
}
Automatic HTTPS via Let's Encrypt
See trillium-acme for automatic certificate provisioning from ACME providers like Let's Encrypt.