clia_rustls_mod/lib.rs
1//! # Rustls - a modern TLS library
2//!
3//! Rustls is a TLS library that aims to provide a good level of cryptographic security,
4//! requires no configuration to achieve that security, and provides no unsafe features or
5//! obsolete cryptography by default.
6//!
7//! Rustls implements TLS1.2 and TLS1.3 for both clients and servers. See [the full
8//! list of protocol features](manual::_04_features).
9//!
10//! ### Platform support
11//!
12//! While Rustls itself is platform independent, by default it uses [`aws-lc-rs`] for implementing
13//! the cryptography in TLS.  See [the aws-lc-rs FAQ][aws-lc-rs-platforms-faq] for more details of the
14//! platform/architecture support constraints in aws-lc-rs.
15//!
16//! [`ring`] is also available via the `ring` crate feature: see
17//! [the supported `ring` target platforms][ring-target-platforms].
18//!
19//! By providing a custom instance of the [`crypto::CryptoProvider`] struct, you
20//! can replace all cryptography dependencies of rustls.  This is a route to being portable
21//! to a wider set of architectures and environments, or compliance requirements.  See the
22//! [`crypto::CryptoProvider`] documentation for more details.
23//!
24//! Specifying `default-features = false` when depending on rustls will remove the
25//! dependency on aws-lc-rs.
26//!
27//! Rustls requires Rust 1.61 or later.
28//!
29//! [ring-target-platforms]: https://github.com/briansmith/ring/blob/2e8363b433fa3b3962c877d9ed2e9145612f3160/include/ring-core/target.h#L18-L64
30//! [`crypto::CryptoProvider`]: crate::crypto::CryptoProvider
31//! [`ring`]: https://crates.io/crates/ring
32//! [aws-lc-rs-platforms-faq]: https://aws.github.io/aws-lc-rs/faq.html#can-i-run-aws-lc-rs-on-x-platform-or-architecture
33//! [`aws-lc-rs`]: https://crates.io/crates/aws-lc-rs
34//!
35//! ### Cryptography providers
36//!
37//! Since Rustls 0.22 it has been possible to choose the provider of the cryptographic primitives
38//! that Rustls uses. This may be appealing if you have specific platform, compliance or feature
39//! requirements that aren't met by the default provider, [`aws-lc-rs`].
40//!
41//! Users that wish to customize the provider in use can do so when constructing `ClientConfig`
42//! and `ServerConfig` instances using the `with_crypto_provider` method on the respective config
43//! builder types. See the [`crypto::CryptoProvider`] documentation for more details.
44//!
45//! #### Built-in providers
46//!
47//! Rustls ships with two built-in providers controlled with associated feature flags:
48//!
49//!   * [`aws-lc-rs`] - enabled by default, available with the `aws_lc_rs` feature flag enabled.
50//!   * [`ring`] - available with the `ring` feature flag enabled.
51//!
52//! See the documentation for [`crypto::CryptoProvider`] for details on how providers are
53//! selected.
54//!
55//! #### Third-party providers
56//!
57//! The community has also started developing third-party providers for Rustls:
58//!
59//!   * [`rustls-mbedtls-provider`] - a provider that uses [`mbedtls`] for cryptography.
60//!   * [`boring-rustls-provider`] - a work-in-progress provider that uses [`boringssl`] for
61//!     cryptography.
62//!   * [`rustls-rustcrypto`] - an experimental provider that uses the crypto primitives
63//!     from [`RustCrypto`] for cryptography.
64//!   * [`rustls-post-quantum`]: an experimental provider that adds support for post-quantum
65//!     key exchange to the default aws-lc-rs provider.
66//!
67//! [`rustls-mbedtls-provider`]: https://github.com/fortanix/rustls-mbedtls-provider
68//! [`mbedtls`]: https://github.com/Mbed-TLS/mbedtls
69//! [`boring-rustls-provider`]: https://github.com/janrueth/boring-rustls-provider
70//! [`boringssl`]: https://github.com/google/boringssl
71//! [`rustls-rustcrypto`]: https://github.com/RustCrypto/rustls-rustcrypto
72//! [`RustCrypto`]: https://github.com/RustCrypto
73//! [`rustls-post-quantum`]: https://crates.io/crates/rustls-post-quantum
74//!
75//! #### Custom provider
76//!
77//! We also provide a simple example of writing your own provider in the [`custom-provider`]
78//! example. This example implements a minimal provider using parts of the [`RustCrypto`]
79//! ecosystem.
80//!
81//! See the [Making a custom CryptoProvider] section of the documentation for more information
82//! on this topic.
83//!
84//! [`custom-provider`]: https://github.com/rustls/rustls/tree/main/provider-example/
85//! [`RustCrypto`]: https://github.com/RustCrypto
86//! [Making a custom CryptoProvider]: https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#making-a-custom-cryptoprovider
87//!
88//! ## Design overview
89//!
90//! Rustls is a low-level library. If your goal is to make HTTPS connections you may prefer
91//! to use a library built on top of Rustls like [hyper] or [ureq].
92//!
93//! [hyper]: https://crates.io/crates/hyper
94//! [ureq]: https://crates.io/crates/ureq
95//!
96//! ### Rustls does not take care of network IO
97//! It doesn't make or accept TCP connections, or do DNS, or read or write files.
98//!
99//! Our [examples] directory contains demos that show how to handle I/O using the
100//! [`stream::Stream`] helper, as well as more complex asynchronous I/O using [`mio`].
101//! If you're already using Tokio for an async runtime you may prefer to use [`tokio-rustls`] instead
102//! of interacting with rustls directly.
103//!
104//! [examples]: examples/README.md
105//! [`tokio-rustls`]: https://github.com/rustls/tokio-rustls
106//!
107//! ### Rustls provides encrypted pipes
108//! These are the [`ServerConnection`] and [`ClientConnection`] types.  You supply raw TLS traffic
109//! on the left (via the [`read_tls()`] and [`write_tls()`] methods) and then read/write the
110//! plaintext on the right:
111//!
112//! [`read_tls()`]: Connection::read_tls
113//! [`write_tls()`]: Connection::read_tls
114//!
115//! ```text
116//!          TLS                                   Plaintext
117//!          ===                                   =========
118//!     read_tls()      +-----------------------+      reader() as io::Read
119//!                     |                       |
120//!           +--------->   ClientConnection    +--------->
121//!                     |          or           |
122//!           <---------+   ServerConnection    <---------+
123//!                     |                       |
124//!     write_tls()     +-----------------------+      writer() as io::Write
125//! ```
126//!
127//! ### Rustls takes care of server certificate verification
128//! You do not need to provide anything other than a set of root certificates to trust.
129//! Certificate verification cannot be turned off or disabled in the main API.
130//!
131//! ## Getting started
132//! This is the minimum you need to do to make a TLS client connection.
133//!
134//! First we load some root certificates.  These are used to authenticate the server.
135//! The simplest way is to depend on the [`webpki_roots`] crate which contains
136//! the Mozilla set of root certificates.
137//!
138//! ```rust,no_run
139//! # #[cfg(feature = "aws-lc-rs")] {
140//! let root_store = rustls::RootCertStore::from_iter(
141//!     webpki_roots::TLS_SERVER_ROOTS
142//!         .iter()
143//!         .cloned(),
144//! );
145//! # }
146//! ```
147//!
148//! [`webpki_roots`]: https://crates.io/crates/webpki-roots
149//!
150//! Next, we make a `ClientConfig`.  You're likely to make one of these per process,
151//! and use it for all connections made by that process.
152//!
153//! ```rust,no_run
154//! # #[cfg(feature = "aws_lc_rs")] {
155//! # let root_store: rustls::RootCertStore = panic!();
156//! let config = rustls::ClientConfig::builder()
157//!     .with_root_certificates(root_store)
158//!     .with_no_client_auth();
159//! # }
160//! ```
161//!
162//! Now we can make a connection.  You need to provide the server's hostname so we
163//! know what to expect to find in the server's certificate.
164//!
165//! ```rust
166//! # #[cfg(feature = "aws_lc_rs")] {
167//! # use rustls;
168//! # use webpki;
169//! # use std::sync::Arc;
170//! # rustls::crypto::aws_lc_rs::default_provider().install_default();
171//! # let root_store = rustls::RootCertStore::from_iter(
172//! #  webpki_roots::TLS_SERVER_ROOTS
173//! #      .iter()
174//! #      .cloned(),
175//! # );
176//! # let config = rustls::ClientConfig::builder()
177//! #     .with_root_certificates(root_store)
178//! #     .with_no_client_auth();
179//! let rc_config = Arc::new(config);
180//! let example_com = "example.com".try_into().unwrap();
181//! let mut client = rustls::ClientConnection::new(rc_config, example_com);
182//! # }
183//! ```
184//!
185//! Now you should do appropriate IO for the `client` object.  If `client.wants_read()` yields
186//! true, you should call `client.read_tls()` when the underlying connection has data.
187//! Likewise, if `client.wants_write()` yields true, you should call `client.write_tls()`
188//! when the underlying connection is able to send data.  You should continue doing this
189//! as long as the connection is valid.
190//!
191//! The return types of `read_tls()` and `write_tls()` only tell you if the IO worked.  No
192//! parsing or processing of the TLS messages is done.  After each `read_tls()` you should
193//! therefore call `client.process_new_packets()` which parses and processes the messages.
194//! Any error returned from `process_new_packets` is fatal to the connection, and will tell you
195//! why.  For example, if the server's certificate is expired `process_new_packets` will
196//! return `Err(InvalidCertificate(Expired))`.  From this point on,
197//! `process_new_packets` will not do any new work and will return that error continually.
198//!
199//! You can extract newly received data by calling `client.reader()` (which implements the
200//! `io::Read` trait).  You can send data to the peer by calling `client.writer()` (which
201//! implements `io::Write` trait).  Note that `client.writer().write()` buffers data you
202//! send if the TLS connection is not yet established: this is useful for writing (say) a
203//! HTTP request, but this is buffered so avoid large amounts of data.
204//!
205//! The following code uses a fictional socket IO API for illustration, and does not handle
206//! errors.
207//!
208//! ```rust,no_run
209//! # #[cfg(feature = "aws_lc_rs")] {
210//! # let mut client = rustls::ClientConnection::new(panic!(), panic!()).unwrap();
211//! # struct Socket { }
212//! # impl Socket {
213//! #   fn ready_for_write(&self) -> bool { false }
214//! #   fn ready_for_read(&self) -> bool { false }
215//! #   fn wait_for_something_to_happen(&self) { }
216//! # }
217//! #
218//! # use std::io::{Read, Write, Result};
219//! # impl Read for Socket {
220//! #   fn read(&mut self, buf: &mut [u8]) -> Result<usize> { panic!() }
221//! # }
222//! # impl Write for Socket {
223//! #   fn write(&mut self, buf: &[u8]) -> Result<usize> { panic!() }
224//! #   fn flush(&mut self) -> Result<()> { panic!() }
225//! # }
226//! #
227//! # fn connect(_address: &str, _port: u16) -> Socket {
228//! #   panic!();
229//! # }
230//! use std::io;
231//! use rustls::Connection;
232//!
233//! client.writer().write(b"GET / HTTP/1.0\r\n\r\n").unwrap();
234//! let mut socket = connect("example.com", 443);
235//! loop {
236//!   if client.wants_read() && socket.ready_for_read() {
237//!     client.read_tls(&mut socket).unwrap();
238//!     client.process_new_packets().unwrap();
239//!
240//!     let mut plaintext = Vec::new();
241//!     client.reader().read_to_end(&mut plaintext).unwrap();
242//!     io::stdout().write(&plaintext).unwrap();
243//!   }
244//!
245//!   if client.wants_write() && socket.ready_for_write() {
246//!     client.write_tls(&mut socket).unwrap();
247//!   }
248//!
249//!   socket.wait_for_something_to_happen();
250//! }
251//! # }
252//! ```
253//!
254//! # Examples
255//!
256//! You can find several client and server examples of varying complexity in the [examples]
257//! directory, including [`tlsserver-mio`](https://github.com/rustls/rustls/blob/main/examples/src/bin/tlsserver-mio.rs)
258//! and [`tlsclient-mio`](https://github.com/rustls/rustls/blob/main/examples/src/bin/tlsclient-mio.rs)
259//! \- full worked examples using [`mio`].
260//!
261//! [`mio`]: https://docs.rs/mio/latest/mio/
262//!
263//! # Crate features
264//! Here's a list of what features are exposed by the rustls crate and what
265//! they mean.
266//!
267//! - `aws_lc_rs` (enabled by default): makes the rustls crate depend on the [`aws-lc-rs`] crate.
268//!   Use `rustls::crypto::aws_lc_rs::default_provider().install_default()` to
269//!   use it as the default `CryptoProvider`, or provide it explicitly
270//!   when making a `ClientConfig` or `ServerConfig`.
271//!
272//!   Note that aws-lc-rs has additional build-time dependencies like cmake.
273//!   See [the documentation](https://aws.github.io/aws-lc-rs/requirements/index.html) for details.
274//!
275//! - `ring`: makes the rustls crate depend on the *ring* crate for cryptography.
276//!   Use `rustls::crypto::ring::default_provider().install_default()` to
277//!   use it as the default `CryptoProvider`, or provide it explicitly
278//!   when making a `ClientConfig` or `ServerConfig`.
279//!
280//! - `fips`: enable support for FIPS140-3-approved cryptography, via the aws-lc-rs crate.
281//!   This feature enables the `aws_lc_rs` feature, which makes the rustls crate depend
282//!   on [aws-lc-rs](https://github.com/aws/aws-lc-rs).  It also changes the default
283//!   for [`ServerConfig::require_ems`] and [`ClientConfig::require_ems`].
284//!
285//!   See [manual::_06_fips] for more details.
286//!
287//! - `tls12` (enabled by default): enable support for TLS version 1.2. Note that, due to the
288//!   additive nature of Cargo features and because it is enabled by default, other crates
289//!   in your dependency graph could re-enable it for your application. If you want to disable
290//!   TLS 1.2 for security reasons, consider explicitly enabling TLS 1.3 only in the config
291//!   builder API.
292//!
293//! - `logging` (enabled by default): make the rustls crate depend on the `log` crate.
294//!   rustls outputs interesting protocol-level messages at `trace!` and `debug!` level,
295//!   and protocol-level errors at `warn!` and `error!` level.  The log messages do not
296//!   contain secret key data, and so are safe to archive without affecting session security.
297//!
298//! - `read_buf`: when building with Rust Nightly, adds support for the unstable
299//!   `std::io::ReadBuf` and related APIs. This reduces costs from initializing
300//!   buffers. Will do nothing on non-Nightly releases.
301//!
302
303// Require docs for public APIs, deny unsafe code, etc.
304#![forbid(unsafe_code, unused_must_use)]
305#![cfg_attr(not(any(read_buf, bench)), forbid(unstable_features))]
306#![deny(
307    clippy::alloc_instead_of_core,
308    clippy::clone_on_ref_ptr,
309    clippy::std_instead_of_core,
310    clippy::use_self,
311    clippy::upper_case_acronyms,
312    trivial_casts,
313    trivial_numeric_casts,
314    missing_docs,
315    unreachable_pub,
316    unused_import_braces,
317    unused_extern_crates,
318    unused_qualifications
319)]
320// Relax these clippy lints:
321// - ptr_arg: this triggers on references to type aliases that are Vec
322//   underneath.
323// - too_many_arguments: some things just need a lot of state, wrapping it
324//   doesn't necessarily make it easier to follow what's going on
325// - new_ret_no_self: we sometimes return `Arc<Self>`, which seems fine
326// - single_component_path_imports: our top-level `use log` import causes
327//   a false positive, https://github.com/rust-lang/rust-clippy/issues/5210
328// - new_without_default: for internal constructors, the indirection is not
329//   helpful
330#![allow(
331    clippy::too_many_arguments,
332    clippy::new_ret_no_self,
333    clippy::ptr_arg,
334    clippy::single_component_path_imports,
335    clippy::new_without_default
336)]
337// Enable documentation for all features on docs.rs
338#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
339// XXX: Because of https://github.com/rust-lang/rust/issues/54726, we cannot
340// write `#![rustversion::attr(nightly, feature(read_buf))]` here. Instead,
341// build.rs set `read_buf` for (only) Rust Nightly to get the same effect.
342//
343// All the other conditional logic in the crate could use
344// `#[rustversion::nightly]` instead of `#[cfg(read_buf)]`; `#[cfg(read_buf)]`
345// is used to avoid needing `rustversion` to be compiled twice during
346// cross-compiling.
347#![cfg_attr(read_buf, feature(read_buf))]
348#![cfg_attr(read_buf, feature(core_io_borrowed_buf))]
349#![cfg_attr(bench, feature(test))]
350#![no_std]
351
352extern crate alloc;
353// This `extern crate` plus the `#![no_std]` attribute changes the default prelude from
354// `std::prelude` to `core::prelude`. That forces one to _explicitly_ import (`use`) everything that
355// is in `std::prelude` but not in `core::prelude`. This helps maintain no-std support as even
356// developers that are not interested in, or aware of, no-std support and / or that never run
357// `cargo build --no-default-features` locally will get errors when they rely on `std::prelude` API.
358#[cfg(any(feature = "std", test))]
359extern crate std;
360
361// Import `test` sysroot crate for `Bencher` definitions.
362#[cfg(bench)]
363#[allow(unused_extern_crates)]
364extern crate test;
365
366// log for logging (optional).
367#[cfg(feature = "logging")]
368use log;
369
370#[cfg(doc)]
371use crate::crypto::CryptoProvider;
372
373#[cfg(not(feature = "logging"))]
374#[macro_use]
375mod log {
376    macro_rules! trace    ( ($($tt:tt)*) => {{}} );
377    macro_rules! debug    ( ($($tt:tt)*) => {{}} );
378    macro_rules! warn     ( ($($tt:tt)*) => {{}} );
379}
380
381#[macro_use]
382mod test_macros;
383
384#[macro_use]
385mod msgs;
386mod common_state;
387mod conn;
388/// Crypto provider interface.
389pub mod crypto;
390mod error;
391mod hash_hs;
392#[cfg(feature = "std")]
393mod limited_cache;
394mod rand;
395mod record_layer;
396#[cfg(feature = "std")]
397mod stream;
398#[cfg(feature = "tls12")]
399mod tls12;
400mod tls13;
401mod vecbuf;
402mod verify;
403#[cfg(test)]
404mod verifybench;
405mod x509;
406#[macro_use]
407mod check;
408mod bs_debug;
409mod builder;
410mod enums;
411mod key_log;
412#[cfg(feature = "std")]
413mod key_log_file;
414mod suites;
415mod versions;
416mod webpki;
417
418/// Internal classes that are used in integration tests.
419/// The contents of this section DO NOT form part of the stable interface.
420#[allow(missing_docs)]
421pub mod internal {
422    /// Low-level TLS message parsing and encoding functions.
423    pub mod msgs {
424        pub mod base {
425            pub use crate::msgs::base::Payload;
426        }
427        pub mod codec {
428            pub use crate::msgs::codec::{Codec, Reader};
429        }
430        pub mod deframer {
431            pub use crate::msgs::deframer::{DeframerVecBuffer, MessageDeframer};
432        }
433        pub mod enums {
434            pub use crate::msgs::enums::{
435                AlertLevel, Compression, EchVersion, HpkeAead, HpkeKdf, HpkeKem, NamedGroup,
436            };
437        }
438        pub mod fragmenter {
439            pub use crate::msgs::fragmenter::MessageFragmenter;
440        }
441        pub mod handshake {
442            pub use crate::msgs::handshake::{
443                CertificateChain, ClientExtension, ClientHelloPayload, DistinguishedName,
444                EchConfig, EchConfigContents, HandshakeMessagePayload, HandshakePayload,
445                HpkeKeyConfig, HpkeSymmetricCipherSuite, KeyShareEntry, Random, SessionId,
446            };
447        }
448        pub mod message {
449            pub use crate::msgs::message::{
450                Message, MessagePayload, OutboundOpaqueMessage, PlainMessage,
451            };
452        }
453        pub mod persist {
454            pub use crate::msgs::persist::ServerSessionValue;
455        }
456    }
457
458    pub mod record_layer {
459        pub use crate::record_layer::RecordLayer;
460    }
461}
462
463/// Unbuffered connection API
464///
465/// This is an alternative to the [`crate::ConnectionCommon`] API that does not internally buffer
466/// TLS nor plaintext data. Instead those buffers are managed by the API user so they have
467/// control over when and how to allocate, resize and dispose of them.
468///
469/// This API is lower level than the `ConnectionCommon` API and is built around a state machine
470/// interface where the API user must handle each state to advance and complete the
471/// handshake process.
472///
473/// Like the `ConnectionCommon` API, no IO happens internally so all IO must be handled by the API
474/// user. Unlike the `ConnectionCommon` API, this API does not make use of the [`std::io::Read`] and
475/// [`std::io::Write`] traits so it's usable in no-std context.
476///
477/// The entry points into this API are [`crate::client::UnbufferedClientConnection::new`],
478/// [`crate::server::UnbufferedServerConnection::new`] and
479/// [`unbuffered::UnbufferedConnectionCommon::process_tls_records`]. The state machine API is
480/// documented in [`unbuffered::ConnectionState`].
481///
482/// # Examples
483///
484/// [`unbuffered-client`] and [`unbuffered-server`] are examples that fully exercise the API in
485/// std, non-async context.
486///
487/// [`unbuffered-client`]: https://github.com/rustls/rustls/blob/main/examples/src/bin/unbuffererd-client.rs
488/// [`unbuffered-server`]: https://github.com/rustls/rustls/blob/main/examples/src/bin/unbuffererd-server.rs
489pub mod unbuffered {
490    pub use crate::conn::unbuffered::{
491        AppDataRecord, ConnectionState, EncodeError, EncodeTlsData, EncryptError,
492        InsufficientSizeError, ReadEarlyData, ReadTraffic, TransmitTlsData, UnbufferedStatus,
493        WriteTraffic,
494    };
495    pub use crate::conn::UnbufferedConnectionCommon;
496}
497
498// The public interface is:
499pub use crate::builder::{ConfigBuilder, ConfigSide, WantsVerifier, WantsVersions};
500pub use crate::common_state::{CommonState, IoState, Side};
501#[cfg(feature = "std")]
502pub use crate::conn::{Connection, Reader, Writer};
503pub use crate::conn::{ConnectionCommon, SideData};
504pub use crate::enums::{
505    AlertDescription, CipherSuite, ContentType, HandshakeType, ProtocolVersion, SignatureAlgorithm,
506    SignatureScheme,
507};
508pub use crate::error::{
509    CertRevocationListError, CertificateError, Error, InvalidMessage, OtherError, PeerIncompatible,
510    PeerMisbehaved,
511};
512pub use crate::key_log::{KeyLog, NoKeyLog};
513#[cfg(feature = "std")]
514pub use crate::key_log_file::KeyLogFile;
515pub use crate::msgs::enums::NamedGroup;
516pub use crate::msgs::ffdhe_groups;
517pub use crate::msgs::handshake::DistinguishedName;
518#[cfg(feature = "std")]
519pub use crate::stream::{Stream, StreamOwned};
520pub use crate::suites::{
521    CipherSuiteCommon, ConnectionTrafficSecrets, ExtractedSecrets, SupportedCipherSuite,
522};
523#[cfg(feature = "std")]
524pub use crate::ticketer::TicketSwitcher;
525#[cfg(feature = "tls12")]
526pub use crate::tls12::Tls12CipherSuite;
527pub use crate::tls13::Tls13CipherSuite;
528pub use crate::verify::DigitallySignedStruct;
529pub use crate::versions::{SupportedProtocolVersion, ALL_VERSIONS, DEFAULT_VERSIONS};
530pub use crate::webpki::RootCertStore;
531
532/// Items for use in a client.
533pub mod client {
534    pub(super) mod builder;
535    mod client_conn;
536    mod common;
537    pub(super) mod handy;
538    mod hs;
539    #[cfg(feature = "tls12")]
540    mod tls12;
541    mod tls13;
542
543    pub use builder::WantsClientCert;
544    pub use client_conn::{
545        ClientConfig, ClientConnectionData, ClientSessionStore, EarlyDataError, ResolvesClientCert,
546        Resumption, Tls12Resumption, UnbufferedClientConnection,
547    };
548    #[cfg(feature = "std")]
549    pub use client_conn::{ClientConnection, WriteEarlyData};
550    #[cfg(feature = "std")]
551    pub use handy::ClientSessionMemoryCache;
552
553    /// Dangerous configuration that should be audited and used with extreme care.
554    pub mod danger {
555        pub use super::builder::danger::DangerousClientConfigBuilder;
556        pub use super::client_conn::danger::DangerousClientConfig;
557        pub use crate::verify::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier};
558    }
559
560    pub use crate::msgs::persist::{Tls12ClientSessionValue, Tls13ClientSessionValue};
561    pub use crate::webpki::{
562        verify_server_cert_signed_by_trust_anchor, verify_server_name, ServerCertVerifierBuilder,
563        VerifierBuilderError, WebPkiServerVerifier,
564    };
565}
566
567pub use client::ClientConfig;
568#[cfg(feature = "std")]
569pub use client::ClientConnection;
570
571/// Items for use in a server.
572pub mod server {
573    pub(crate) mod builder;
574    mod common;
575    pub(crate) mod handy;
576    mod hs;
577    mod server_conn;
578    #[cfg(feature = "tls12")]
579    mod tls12;
580    mod tls13;
581
582    pub use builder::WantsServerCert;
583    pub use handy::NoServerSessionStorage;
584    #[cfg(feature = "std")]
585    pub use handy::ResolvesServerCertUsingSni;
586    #[cfg(feature = "std")]
587    pub use handy::ServerSessionMemoryCache;
588    pub use server_conn::{
589        Accepted, ClientHello, ProducesTickets, ResolvesServerCert, ServerConfig,
590        ServerConnectionData, StoresServerSessions, UnbufferedServerConnection,
591    };
592    #[cfg(feature = "std")]
593    pub use server_conn::{AcceptedAlert, Acceptor, ReadEarlyData, ServerConnection};
594
595    pub use crate::verify::NoClientAuth;
596    pub use crate::webpki::{
597        ClientCertVerifierBuilder, ParsedCertificate, VerifierBuilderError, WebPkiClientVerifier,
598    };
599
600    /// Dangerous configuration that should be audited and used with extreme care.
601    pub mod danger {
602        pub use crate::verify::{ClientCertVerified, ClientCertVerifier};
603    }
604}
605
606pub use server::ServerConfig;
607#[cfg(feature = "std")]
608pub use server::ServerConnection;
609
610/// All defined protocol versions appear in this module.
611///
612/// ALL_VERSIONS is a provided as an array of all of these values.
613pub mod version {
614    #[cfg(feature = "tls12")]
615    pub use crate::versions::TLS12;
616    pub use crate::versions::TLS13;
617}
618
619/// Re-exports the contents of the [rustls-pki-types](https://docs.rs/rustls-pki-types) crate for easy access
620pub mod pki_types {
621    pub use pki_types::*;
622}
623
624/// Message signing interfaces.
625pub mod sign {
626    pub use crate::crypto::signer::{CertifiedKey, Signer, SigningKey};
627}
628
629/// APIs for implementing QUIC TLS
630pub mod quic;
631
632#[cfg(feature = "std")]
633/// APIs for implementing TLS tickets
634pub mod ticketer;
635
636/// This is the rustls manual.
637pub mod manual;
638
639pub mod time_provider;