pub struct ClientTlsConfigBuilder { /* private fields */ }Expand description
Incremental builder for ClientTlsConfig.
Implementations§
Source§impl ClientTlsConfigBuilder
impl ClientTlsConfigBuilder
Sourcepub fn ca(self, src: PemSource) -> Self
pub fn ca(self, src: PemSource) -> Self
Set the trusted CA bundle (verifies the server’s certificate).
Sourcepub fn client_cert(self, src: PemSource) -> Self
pub fn client_cert(self, src: PemSource) -> Self
Set the client certificate chain.
Sourcepub fn client_key(self, src: PemSource) -> Self
pub fn client_key(self, src: PemSource) -> Self
Set the client private key.
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 HTTP (default is empty).
Sourcepub fn ca_pem_file(self, path: impl Into<PathBuf>) -> Self
pub fn ca_pem_file(self, path: impl Into<PathBuf>) -> Self
Convenience: trusted CA bundle from a file path.
Sourcepub fn ca_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
pub fn ca_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
Convenience: trusted CA bundle from in-memory bytes.
Sourcepub fn client_cert_pem_file(self, path: impl Into<PathBuf>) -> Self
pub fn client_cert_pem_file(self, path: impl Into<PathBuf>) -> Self
Convenience: client cert chain from a file path.
Sourcepub fn client_cert_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
pub fn client_cert_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
Convenience: client cert chain from in-memory bytes.
Sourcepub fn client_key_pem_file(self, path: impl Into<PathBuf>) -> Self
pub fn client_key_pem_file(self, path: impl Into<PathBuf>) -> Self
Convenience: client private key from a file path.
Sourcepub fn client_key_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
pub fn client_key_pem_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
Convenience: client private key from in-memory bytes.
Sourcepub fn build(self) -> Result<ClientTlsConfig, TlsError>
pub fn build(self) -> Result<ClientTlsConfig, TlsError>
Finalize the configuration.
Requires ca.
Rejects an unpaired client cert/key with TlsError::MissingField ("client_cert" or "client_key").
Does no I/O: the PEM sources are read by ClientTlsConfig::into_rustls_config.
§Example
use solti_tls::{ClientTlsConfig, TlsError};
// A client cert without its key is rejected.
let err = ClientTlsConfig::builder()
.ca_pem_bytes(b"-----BEGIN CERTIFICATE-----\n...".to_vec())
.client_cert_pem_bytes(b"cert".to_vec())
.build()
.unwrap_err();
assert!(matches!(err, TlsError::MissingField("client_key")));Trait Implementations§
Source§impl Clone for ClientTlsConfigBuilder
impl Clone for ClientTlsConfigBuilder
Source§fn clone(&self) -> ClientTlsConfigBuilder
fn clone(&self) -> ClientTlsConfigBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more