pub struct ClientConfig {
pub alpn_protocols: Vec<Vec<u8>>,
pub resumption: Resumption,
pub max_fragment_size: Option<usize>,
pub client_auth_cert_resolver: Arc<dyn ResolvesClientCert>,
pub enable_sni: bool,
pub key_log: Arc<dyn KeyLog>,
pub enable_secret_extraction: bool,
pub enable_early_data: bool,
/* private fields */
}
Expand description
Common configuration for (typically) all connections made by a program.
Making one of these is cheap, though one of the inputs may be expensive: gathering trust roots
from the operating system to add to the RootCertStore
passed to with_root_certificates()
(the rustls-native-certs crate is often used for this) may take on the order of a few hundred
milliseconds.
These must be created via the ClientConfig::builder()
or ClientConfig::builder_with_provider()
function.
§Defaults
ClientConfig::max_fragment_size
: the default isNone
(meaning 16kB).ClientConfig::resumption
: supports resumption with up to 256 server names, using session ids or tickets, with a max of eight tickets per server.ClientConfig::alpn_protocols
: the default is empty – no ALPN protocol is negotiated.ClientConfig::key_log
: key material is not logged.
Fields§
§alpn_protocols: Vec<Vec<u8>>
Which ALPN protocols we include in our client hello. If empty, no ALPN extension is sent.
resumption: Resumption
How and when the client can resume a previous session.
max_fragment_size: Option<usize>
The maximum size of plaintext input to be emitted in a single TLS record. A value of None is equivalent to the TLS maximum of 16 kB.
rustls enforces an arbitrary minimum of 32 bytes for this field. Out of range values are reported as errors from ClientConnection::new.
Setting this value to a little less than the TCP MSS may improve latency for stream-y workloads.
client_auth_cert_resolver: Arc<dyn ResolvesClientCert>
How to decide what client auth certificate/keys to use.
enable_sni: bool
Whether to send the Server Name Indication (SNI) extension during the client handshake.
The default is true.
key_log: Arc<dyn KeyLog>
How to output key material for debugging. The default does nothing.
enable_secret_extraction: bool
Allows traffic secrets to be extracted after the handshake, e.g. for kTLS setup.
enable_early_data: bool
Whether to send data on the first flight (“early data”) in TLS 1.3 handshakes.
The default is false.
Implementations§
source§impl ClientConfig
impl ClientConfig
sourcepub fn builder() -> ConfigBuilder<Self, WantsVerifier>
pub fn builder() -> ConfigBuilder<Self, WantsVerifier>
Create a builder for a client configuration with the default
CryptoProvider
: crypto::ring::default_provider
and safe ciphersuite and
protocol defaults.
For more information, see the ConfigBuilder
documentation.
sourcepub fn builder_with_protocol_versions(
versions: &[&'static SupportedProtocolVersion],
) -> ConfigBuilder<Self, WantsVerifier>
pub fn builder_with_protocol_versions( versions: &[&'static SupportedProtocolVersion], ) -> ConfigBuilder<Self, WantsVerifier>
Create a builder for a client configuration with the default
CryptoProvider
: crypto::ring::default_provider
, safe ciphersuite defaults and
the provided protocol versions.
Panics if provided an empty slice of supported versions.
For more information, see the ConfigBuilder
documentation.
sourcepub fn builder_with_provider(
provider: Arc<CryptoProvider>,
) -> ConfigBuilder<Self, WantsVersions>
pub fn builder_with_provider( provider: Arc<CryptoProvider>, ) -> ConfigBuilder<Self, WantsVersions>
Create a builder for a client configuration with a specific CryptoProvider
.
This will use the provider’s configured ciphersuites. You must additionally choose
which protocol versions to enable, using with_protocol_versions
or
with_safe_default_protocol_versions
and handling the Result
in case a protocol
version is not supported by the provider’s ciphersuites.
For more information, see the ConfigBuilder
documentation.
sourcepub fn dangerous(&mut self) -> DangerousClientConfig<'_>
pub fn dangerous(&mut self) -> DangerousClientConfig<'_>
Access configuration options whose use is dangerous and requires extra care.
Trait Implementations§
source§impl Clone for ClientConfig
impl Clone for ClientConfig
source§impl Debug for ClientConfig
impl Debug for ClientConfig
impl ConfigSide for ClientConfig
Auto Trait Implementations§
impl Freeze for ClientConfig
impl !RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl !UnwindSafe for ClientConfig
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)