1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Which TLS provider this build uses, decided in one place.
//!
//! Rustls ships no cipher suite of its own. It reads its crate features and, when they name none,
//! `CryptoProvider::get_default_or_install_from_crate_features()` panics — deferred all the way to
//! the first connection, because there is no `compile_error!` anywhere in rustls for it. So a build
//! with no provider is green, starts, announces, and dies the moment it reaches the network.
//!
//! Two consumers here reach TLS by different roads and both would hit that:
//!
//! - `tokio-tungstenite` builds a client config inside `connect_async`, so a `wss://` dial panics.
//! - `reqwest`, on the `rustls-no-provider` feature, panics while *building the client* — before a
//! request, before a URL, and regardless of scheme. That feature means "the application installs
//! it", and this module is the application saying so.
//!
//! Installing rather than leaving rustls to read its own features is also what makes the answer
//! deterministic: `from_crate_features()` returns `None` when *both* providers are linked, which is
//! a panic for the ambiguity rather than for the absence, and a dependency graph can arrive at both
//! without anyone choosing it.
/// Put this build's chosen provider in place, once.
///
/// `install_default` reports an error rather than panicking once something is already installed,
/// and an application that installed its own is exactly who should win — so the result is dropped.
pub
pub
pub
/// Whether this build can do TLS at all.
///
/// Asked before a socket is opened or a client is built, so the answer is about the build and never
/// about the network.
///
/// One case answers `false` while rustls would in fact have coped: another crate in the graph
/// switched on `rustls/ring` or `rustls/aws-lc-rs`, nothing installed a default, and rustls would
/// have read that feature at the last moment. There is no way to ask it — the function that reads
/// those features is private and the one that is public panics. Refusing is the side to err on: the
/// message names both features and `install_default`, and either is one line, whereas the other
/// direction is a panic in a stranger's process.
pub
/// The same question for a URL that may not need an answer. `ws://` carries no TLS, so a missing
/// provider is not what stops it — refusing it would break every plaintext deployment for a reason
/// that does not apply to it.
pub