pub struct ServerConfig {Show 18 fields
pub cipher_suite_selector: &'static dyn CipherSuiteSelector,
pub kx_selector: &'static dyn KeyExchangeSelector,
pub max_fragment_size: Option<usize>,
pub session_storage: Arc<dyn StoresServerSessions>,
pub ticketer: Option<Arc<dyn TicketProducer>>,
pub cert_resolver: Arc<dyn ServerCredentialResolver>,
pub alpn_protocols: Vec<ApplicationProtocol<'static>>,
pub key_log: Arc<dyn KeyLog>,
pub enable_secret_extraction: bool,
pub max_early_data_size: u32,
pub send_half_rtt_data: bool,
pub send_tls13_tickets: Tls13Tickets,
pub require_ems: bool,
pub time_provider: Arc<dyn TimeProvider>,
pub cert_compressors: Vec<&'static dyn CertCompressor>,
pub cert_compression_cache: Arc<CompressionCache>,
pub cert_decompressors: Vec<&'static dyn CertDecompressor>,
pub invalid_sni_policy: InvalidSniPolicy,
/* private fields */
}Expand description
Common configuration for a set of server sessions.
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 a ClientVerifier
builder may take on the order of a few hundred milliseconds.
These must be created via the ServerConfig::builder() or ServerConfig::builder_with_details()
function.
§Sharing resumption storage between ServerConfigs
In a program using many ServerConfigs it may improve resumption rates
(which has a significant impact on connection performance) if those
configs share ServerConfig::session_storage or ServerConfig::ticketer.
However, caution is needed: other fields influence the security of a session
and resumption between them can be surprising. If sharing
ServerConfig::session_storage or ServerConfig::ticketer between two
ServerConfigs, you should also evaluate the following fields and ensure
they are equivalent:
ServerConfig::verifier– client authentication requirements,ServerConfig::cert_resolver– server identities.
To illustrate, imagine two ServerConfigs A and B. A requires
client authentication, B does not. If A and B shared a resumption store,
it would be possible for a session originated by B (that is, an unauthenticated client)
to be inserted into the store, and then resumed by A. This would give a false
impression to the user of A that the client was authenticated. This is possible
whether the resumption is performed statefully (via ServerConfig::session_storage)
or statelessly (via ServerConfig::ticketer).
Unlike ClientConfig, rustls does not enforce any policy here.
Fields§
§cipher_suite_selector: &'static dyn CipherSuiteSelectorHow to select a cipher suite to use for a TLS session.
The default is PreferClientOrder.
kx_selector: &'static dyn KeyExchangeSelectorHow to select a key exchange group to use for a TLS connection.
The default is PreferClientOrder.
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, and this is the default.
rustls enforces an arbitrary minimum of 32 bytes for this field. Out of range values are reported as errors from Connection::new.
Setting this value to a little less than the TCP MSS may improve latency for stream-y workloads.
session_storage: Arc<dyn StoresServerSessions>How to store client sessions.
The default stores 256 sessions in memory.
See ServerConfig for a warning related to this field.
ticketer: Option<Arc<dyn TicketProducer>>How to produce tickets.
The default is None which means ticket-based resumption in TLS1.2 and stateless resumption
in TLS1.3 are not available.
See ServerConfig for a warning related to this field.
cert_resolver: Arc<dyn ServerCredentialResolver>How to choose a server cert and key. This is usually set by ConfigBuilder::with_single_cert or ConfigBuilder::with_server_credential_resolver.
alpn_protocols: Vec<ApplicationProtocol<'static>>Protocol names we support, most preferred first.
If empty we don’t do ALPN at all. This is the default.
key_log: Arc<dyn KeyLog>How to output key material for debugging.
The default does nothing and so key material is not logged.
See RFC 9850 for background.
enable_secret_extraction: boolAllows traffic secrets to be extracted after the handshake, e.g. for kTLS setup.
max_early_data_size: u32Amount of early data to accept for sessions created by this config. Specify 0 to disable early data. The default is 0.
Read the early data via
MessageHandler::next_early_data().
The units for this are both plaintext bytes, and ciphertext bytes, depending on whether the server accepts a client’s early_data or not. It is therefore recommended to include some slop in this value to account for the unknown amount of ciphertext expansion in the latter case.
send_half_rtt_data: boolWhether the server should send “0.5RTT” data. This means the server sends data after its first flight of handshake messages, without waiting for the client to complete the handshake.
This can improve TTFB latency for either server-speaks-first protocols,
or client-speaks-first protocols when paired with “0RTT” data. This
comes at the cost of a subtle weakening of the normal handshake
integrity guarantees that TLS provides. Note that the initial
ClientHello is indirectly authenticated because it is included
in the transcript used to derive the keys used to encrypt the data.
This only applies to TLS1.3 connections. TLS1.2 connections cannot do this optimisation and this setting is ignored for them. It is also ignored for TLS1.3 connections that even attempt client authentication.
This defaults to false. This means the first application data
sent by the server comes after receiving and validating the client’s
handshake up to the Finished message. This is the safest option.
send_tls13_tickets: Tls13TicketsHow many TLS1.3 tickets to send immediately after a successful handshake.
Because TLS1.3 tickets are single-use, this allows a client to perform multiple resumptions.
The default means 2 tickets are sent, with a maximum of 2.
See Tls13Tickets for the meaning of the default and maximum
counts.
require_ems: boolIf set to true, requires the client to support the extended
master secret extraction method defined in RFC 7627.
The default is true if the configured CryptoProvider is FIPS-compliant,
false otherwise.
It must be set to true to meet FIPS requirement mentioned in section
D.Q Transition of the TLS 1.2 KDF to Support the Extended Master
Secret from FIPS 140-3 IG.pdf.
time_provider: Arc<dyn TimeProvider>Provides the current system time
cert_compressors: Vec<&'static dyn CertCompressor>How to compress the server’s certificate chain.
If a client supports this extension, and advertises support for one of the compression algorithms included here, the server certificate will be compressed according to RFC 8879.
This only applies to TLS1.3 connections. It is ignored for TLS1.2 connections.
The default depends on the crate features, see compress::default_cert_compressors().
cert_compression_cache: Arc<CompressionCache>Caching for compressed certificates.
This is optional: compress::CompressionCache::Disabled gives
a cache that does no caching.
The default caches the most recently used 4 compressions.
cert_decompressors: Vec<&'static dyn CertDecompressor>How to decompress the clients’s certificate chain.
If this is non-empty, the RFC 8879 certificate compression extension is offered when requesting client authentication, and any compressed certificates are transparently decompressed during the handshake.
This only applies to TLS1.3 connections. It is ignored for TLS1.2 connections.
The default depends on the crate features, see compress::default_cert_decompressors().
invalid_sni_policy: InvalidSniPolicyPolicy for how an invalid Server Name Indication (SNI) value from a client is handled.
The default rejects IP addresses in SNI extensions, which is mandated behaviour.
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn builder(
provider: Arc<CryptoProvider>,
) -> ConfigBuilder<Self, WantsVerifier>
pub fn builder( provider: Arc<CryptoProvider>, ) -> ConfigBuilder<Self, WantsVerifier>
Create a builder for a server configuration with a specific CryptoProvider.
This will use the provider’s configured ciphersuites. This implies which TLS protocol versions are enabled.
This function always succeeds. Any internal consistency problems with provider
are reported at the end of the builder process.
For more information, see the ConfigBuilder documentation.
Sourcepub fn builder_with_details(
provider: Arc<CryptoProvider>,
time_provider: Arc<dyn TimeProvider>,
) -> ConfigBuilder<Self, WantsVerifier>
pub fn builder_with_details( provider: Arc<CryptoProvider>, time_provider: Arc<dyn TimeProvider>, ) -> ConfigBuilder<Self, WantsVerifier>
Create a builder for a server configuration with no default implementation details.
This API must be used by no_std users.
You must provide a specific TimeProvider.
You must provide a specific CryptoProvider.
This will use the provider’s configured ciphersuites. This implies which TLS protocol versions are enabled.
This function always succeeds. Any internal consistency problems with provider
are reported at the end of the builder process.
For more information, see the ConfigBuilder documentation.
Sourcepub fn fips(&self) -> FipsStatus
pub fn fips(&self) -> FipsStatus
Return the FIPS validation status for connections made with this configuration.
This is different from CryptoProvider::fips(): CryptoProvider::fips()
is concerned only with cryptography, whereas this also covers TLS-level
configuration that NIST recommends.
Sourcepub fn provider(&self) -> &Arc<CryptoProvider> ⓘ
pub fn provider(&self) -> &Arc<CryptoProvider> ⓘ
Return the crypto provider used to construct this server configuration.