pub struct ServerTlsConfigBuilder { /* private fields */ }Expand description
Incremental builder for ServerTlsConfig.
Implementations§
Source§impl ServerTlsConfigBuilder
impl ServerTlsConfigBuilder
Sourcepub fn with_alpn<I, S>(self, protocols: I) -> Self
pub fn with_alpn<I, S>(self, protocols: I) -> Self
Set the ALPN protocol list, in preference order.
Pass ["h2"] for gRPC-only, ["h2", "http/1.1"] for axum HTTP.
Default is empty (no ALPN negotiation).
Sourcepub fn cert_pem_file(self, path: impl Into<PathBuf>) -> Self
pub fn cert_pem_file(self, path: impl Into<PathBuf>) -> Self
Convenience: set the server cert chain from a file path.
Sourcepub fn cert_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
pub fn cert_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
Convenience: set the server cert chain from in-memory bytes.
Sourcepub fn key_pem_file(self, path: impl Into<PathBuf>) -> Self
pub fn key_pem_file(self, path: impl Into<PathBuf>) -> Self
Convenience: set the server private key from a file path.
Sourcepub fn key_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
pub fn key_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
Convenience: set the server private key from in-memory bytes.
Sourcepub fn require_client_ca_pem_file(self, path: impl Into<PathBuf>) -> Self
pub fn require_client_ca_pem_file(self, path: impl Into<PathBuf>) -> Self
Convenience: enable mTLS with a CA bundle from a file path.
Sourcepub fn require_client_ca_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
pub fn require_client_ca_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
Convenience: enable mTLS with a CA bundle from in-memory bytes.
Sourcepub fn require_client_ca(self, src: PemSource) -> Self
pub fn require_client_ca(self, src: PemSource) -> Self
Require client certificates signed by this CA bundle (turns on mTLS).
Sourcepub fn build(self) -> Result<ServerTlsConfig, TlsError>
pub fn build(self) -> Result<ServerTlsConfig, TlsError>
Finalize the configuration.
Validates that cert and key are present (else TlsError::MissingField).
Does no I/O - the PEM sources are read later by ServerTlsConfig::into_rustls_config.
§Example
use solti_tls::ServerTlsConfig;
let cfg = ServerTlsConfig::builder()
.cert_pem_bytes(b"-----BEGIN CERTIFICATE-----\n...".to_vec())
.key_pem_bytes(b"-----BEGIN PRIVATE KEY-----\n...".to_vec())
.with_alpn(["h2"])
.build()
.unwrap();
assert!(cfg.client_ca.is_none()); // standard TLS until require_client_caTrait Implementations§
Source§impl Clone for ServerTlsConfigBuilder
impl Clone for ServerTlsConfigBuilder
Source§fn clone(&self) -> ServerTlsConfigBuilder
fn clone(&self) -> ServerTlsConfigBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more