Skip to content

Commit e3bf090

Browse files
authored
docs: explain TLS backend features better (#2117)
1 parent 1bd939b commit e3bf090

File tree

2 files changed

+50
-16
lines changed

2 files changed

+50
-16
lines changed

src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! - Plain bodies, [JSON](#json), [urlencoded](#forms), [multipart]
1616
//! - Customizable [redirect policy](#redirect-policies)
1717
//! - HTTP [Proxies](#proxies)
18-
//! - Uses system-native [TLS](#tls)
18+
//! - Uses [TLS](#tls) by default
1919
//! - Cookies
2020
//!
2121
//! The [`reqwest::Client`][client] is asynchronous. For applications wishing
@@ -149,17 +149,18 @@
149149
//!
150150
//! ## TLS
151151
//!
152-
//! By default, a `Client` will make use of system-native transport layer
153-
//! security to connect to HTTPS destinations. This means schannel on Windows,
154-
//! Security-Framework on macOS, and OpenSSL on Linux.
152+
//! A `Client` will use transport layer security (TLS) by default to connect to
153+
//! HTTPS destinations.
155154
//!
156-
//! - Additional X509 certificates can be configured on a `ClientBuilder` with the
157-
//! [`Certificate`] type.
155+
//! - Additional server certificates can be configured on a `ClientBuilder`
156+
//! with the [`Certificate`] type.
158157
//! - Client certificates can be added to a `ClientBuilder` with the
159158
//! [`Identity`] type.
160159
//! - Various parts of TLS can also be configured or even disabled on the
161160
//! `ClientBuilder`.
162161
//!
162+
//! See more details in the [`tls`] module.
163+
//!
163164
//! ## WASM
164165
//!
165166
//! The Client implementation automatically switches to the WASM one when the target_arch is wasm32,

src/tls.rs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,48 @@
1-
//! TLS configuration
1+
//! TLS configuration and types
22
//!
3-
//! By default, a `Client` will make use of system-native transport layer
4-
//! security to connect to HTTPS destinations. This means schannel on Windows,
5-
//! Security-Framework on macOS, and OpenSSL on Linux.
3+
//! A `Client` will use transport layer security (TLS) by default to connect to
4+
//! HTTPS destinations.
65
//!
7-
//! - Additional X509 certificates can be configured on a `ClientBuilder` with the
8-
//! [`Certificate`] type.
9-
//! - Client certificates can be added to a `ClientBuilder` with the
10-
//! [`Identity`] type.
11-
//! - Various parts of TLS can also be configured or even disabled on the
12-
//! `ClientBuilder`.
6+
//! # Backends
7+
//!
8+
//! reqwest supports several TLS backends, enabled with Cargo features.
9+
//!
10+
//! ## default-tls
11+
//!
12+
//! reqwest will pick a TLS backend by default. This is true when the
13+
//! `default-tls` feature is enabled.
14+
//!
15+
//! While it currently uses `native-tls`, the feature set is designed to only
16+
//! enable configuration that is shared among available backends. This allows
17+
//! reqwest to change the default to `rustls` (or another) at some point in the
18+
//! future.
19+
//!
20+
//! <div class="warning">This feature is enabled by default, and takes
21+
//! precedence if any other crate enables it. This is true even if you declare
22+
//! `features = []`. You must set `no-default-features = false` instead.</div>
23+
//!
24+
//! Since Cargo features are additive, other crates in your dependency tree can
25+
//! cause the default backend to be enabled. If you wish to ensure your
26+
//! `Client` uses a specific backend, call the appropriate builder methods
27+
//! (such as [`use_rustls_tls()`][]).
28+
//!
29+
//! [`use_rustls_tls()`]: crate::ClientBuilder::use_rustls_tls()
30+
//!
31+
//! ## native-tls
32+
//!
33+
//! This backend uses the [native-tls][] crate. That will try to use the system
34+
//! TLS on Windows and Mac, and OpenSSL on Linux targets.
35+
//!
36+
//! Enabling the feature explicitly allows for `native-tls`-specific
37+
//! configuration options.
38+
//!
39+
//! [native-tls]: https://crates.io/crates/native-tls
40+
//!
41+
//! ## rustls-tls
42+
//!
43+
//! This backend uses the [rustls][] crate, a TLS library written in Rust.
44+
//!
45+
//! [rustls]: https://crates.io/crates/rustls
1346
1447
#[cfg(feature = "__rustls")]
1548
use rustls::{

0 commit comments

Comments
 (0)