wreq-rb 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +1922 -397
- data/LICENSE +203 -0
- data/README.md +19 -15
- data/ext/wreq_rb/Cargo.toml +4 -6
- data/ext/wreq_rb/src/client.rs +41 -48
- data/lib/wreq-rb/version.rb +1 -1
- data/patches/0001-add-transfer-size-tracking.patch +76 -67
- data/vendor/wreq/Cargo.toml +119 -71
- data/vendor/wreq/README.md +25 -20
- data/vendor/wreq/bench/http1.rs +25 -0
- data/vendor/wreq/bench/http1_over_tls.rs +25 -0
- data/vendor/wreq/bench/http2.rs +25 -0
- data/vendor/wreq/bench/http2_over_tls.rs +25 -0
- data/vendor/wreq/bench/support/bench.rs +91 -0
- data/vendor/wreq/bench/support/client.rs +217 -0
- data/vendor/wreq/bench/support/server.rs +188 -0
- data/vendor/wreq/bench/support.rs +56 -0
- data/vendor/wreq/examples/cert_store.rs +4 -4
- data/vendor/wreq/examples/{emulation.rs → emulate.rs} +2 -2
- data/vendor/wreq/examples/http2_websocket.rs +2 -2
- data/vendor/wreq/examples/keylog.rs +3 -3
- data/vendor/wreq/examples/{request_with_emulation.rs → request_with_emulate.rs} +2 -2
- data/vendor/wreq/examples/rt.rs +23 -0
- data/vendor/wreq/src/client/body.rs +23 -61
- data/vendor/wreq/src/client/emulate.rs +119 -0
- data/vendor/wreq/src/client/{http/future.rs → future.rs} +11 -32
- data/vendor/wreq/src/client/{http → layer}/client/pool.rs +66 -61
- data/vendor/wreq/src/client/{http → layer}/client.rs +416 -270
- data/vendor/wreq/src/client/layer/config.rs +27 -6
- data/vendor/wreq/src/client/layer/decoder.rs +9 -4
- data/vendor/wreq/src/client/layer/redirect/future.rs +6 -3
- data/vendor/wreq/src/client/layer/redirect.rs +4 -5
- data/vendor/wreq/src/client/layer/retry.rs +8 -5
- data/vendor/wreq/src/client/layer/timeout/body.rs +15 -6
- data/vendor/wreq/src/client/layer/timeout/future.rs +23 -18
- data/vendor/wreq/src/client/layer/timeout.rs +24 -74
- data/vendor/wreq/src/client/layer.rs +1 -2
- data/vendor/wreq/src/client/multipart.rs +137 -154
- data/vendor/wreq/src/client/request.rs +202 -118
- data/vendor/wreq/src/client/response.rs +46 -45
- data/vendor/wreq/src/client/upgrade.rs +15 -0
- data/vendor/wreq/src/client/ws.rs +73 -25
- data/vendor/wreq/src/client.rs +1655 -17
- data/vendor/wreq/src/config.rs +11 -11
- data/vendor/wreq/src/{client/conn → conn}/connector.rs +139 -137
- data/vendor/wreq/src/conn/descriptor.rs +143 -0
- data/vendor/wreq/src/conn/http.rs +484 -0
- data/vendor/wreq/src/conn/net/io.rs +75 -0
- data/vendor/wreq/src/conn/net/tcp/compio.rs +71 -0
- data/vendor/wreq/src/conn/net/tcp/tokio.rs +57 -0
- data/vendor/wreq/src/conn/net/tcp.rs +561 -0
- data/vendor/wreq/src/conn/net/uds/compio.rs +60 -0
- data/vendor/wreq/src/{client/conn/uds.rs → conn/net/uds/tokio.rs} +18 -12
- data/vendor/wreq/src/conn/net/uds.rs +11 -0
- data/vendor/wreq/src/conn/net.rs +130 -0
- data/vendor/wreq/src/{client/conn → conn}/proxy/socks.rs +2 -9
- data/vendor/wreq/src/{client/conn → conn}/proxy/tunnel.rs +21 -56
- data/vendor/wreq/src/conn/tls_info.rs +47 -0
- data/vendor/wreq/src/{client/conn.rs → conn.rs} +202 -54
- data/vendor/wreq/src/cookie.rs +302 -142
- data/vendor/wreq/src/dns/gai/compio.rs +77 -0
- data/vendor/wreq/src/dns/gai/tokio.rs +90 -0
- data/vendor/wreq/src/dns/gai.rs +14 -164
- data/vendor/wreq/src/dns/hickory.rs +16 -23
- data/vendor/wreq/src/dns/resolve.rs +7 -41
- data/vendor/wreq/src/dns.rs +90 -7
- data/vendor/wreq/src/error.rs +57 -31
- data/vendor/wreq/src/ext.rs +25 -0
- data/vendor/wreq/src/group.rs +211 -0
- data/vendor/wreq/src/header.rs +100 -112
- data/vendor/wreq/src/lib.rs +124 -73
- data/vendor/wreq/src/proxy.rs +6 -20
- data/vendor/wreq/src/redirect.rs +1 -1
- data/vendor/wreq/src/rt.rs +208 -0
- data/vendor/wreq/src/sync.rs +97 -98
- data/vendor/wreq/src/tls/compress.rs +124 -0
- data/vendor/wreq/src/tls/conn/ext.rs +54 -45
- data/vendor/wreq/src/tls/conn/service.rs +14 -18
- data/vendor/wreq/src/tls/conn.rs +169 -241
- data/vendor/wreq/src/tls/keylog.rs +68 -5
- data/vendor/wreq/src/tls/session.rs +205 -0
- data/vendor/wreq/src/tls/{x509 → trust}/identity.rs +4 -21
- data/vendor/wreq/src/tls/{x509/parser.rs → trust/parse.rs} +1 -1
- data/vendor/wreq/src/tls/{x509 → trust}/store.rs +42 -81
- data/vendor/wreq/src/tls/{x509.rs → trust.rs} +8 -2
- data/vendor/wreq/src/tls.rs +489 -25
- data/vendor/wreq/src/trace.rs +0 -12
- data/vendor/wreq/src/util.rs +1 -1
- data/vendor/wreq/tests/badssl.rs +10 -10
- data/vendor/wreq/tests/client.rs +3 -9
- data/vendor/wreq/tests/cookie.rs +6 -8
- data/vendor/wreq/tests/{emulation.rs → emulate.rs} +130 -22
- data/vendor/wreq/tests/multipart.rs +43 -1
- data/vendor/wreq/tests/proxy.rs +1 -1
- data/vendor/wreq/tests/support/layer.rs +1 -0
- metadata +49 -71
- data/patches/0002-add-cancel-connections.patch +0 -181
- data/vendor/wreq/src/client/conn/conn.rs +0 -231
- data/vendor/wreq/src/client/conn/http.rs +0 -1023
- data/vendor/wreq/src/client/conn/tls_info.rs +0 -98
- data/vendor/wreq/src/client/core/body/incoming.rs +0 -485
- data/vendor/wreq/src/client/core/body/length.rs +0 -118
- data/vendor/wreq/src/client/core/body.rs +0 -34
- data/vendor/wreq/src/client/core/common/buf.rs +0 -149
- data/vendor/wreq/src/client/core/common/rewind.rs +0 -141
- data/vendor/wreq/src/client/core/common/watch.rs +0 -76
- data/vendor/wreq/src/client/core/common.rs +0 -3
- data/vendor/wreq/src/client/core/conn/http1.rs +0 -342
- data/vendor/wreq/src/client/core/conn/http2.rs +0 -307
- data/vendor/wreq/src/client/core/conn.rs +0 -11
- data/vendor/wreq/src/client/core/dispatch.rs +0 -299
- data/vendor/wreq/src/client/core/error.rs +0 -435
- data/vendor/wreq/src/client/core/ext.rs +0 -201
- data/vendor/wreq/src/client/core/http1.rs +0 -178
- data/vendor/wreq/src/client/core/http2.rs +0 -483
- data/vendor/wreq/src/client/core/proto/h1/conn.rs +0 -988
- data/vendor/wreq/src/client/core/proto/h1/decode.rs +0 -1170
- data/vendor/wreq/src/client/core/proto/h1/dispatch.rs +0 -684
- data/vendor/wreq/src/client/core/proto/h1/encode.rs +0 -580
- data/vendor/wreq/src/client/core/proto/h1/io.rs +0 -879
- data/vendor/wreq/src/client/core/proto/h1/role.rs +0 -694
- data/vendor/wreq/src/client/core/proto/h1.rs +0 -104
- data/vendor/wreq/src/client/core/proto/h2/client.rs +0 -650
- data/vendor/wreq/src/client/core/proto/h2/ping.rs +0 -539
- data/vendor/wreq/src/client/core/proto/h2.rs +0 -379
- data/vendor/wreq/src/client/core/proto/headers.rs +0 -138
- data/vendor/wreq/src/client/core/proto.rs +0 -58
- data/vendor/wreq/src/client/core/rt/bounds.rs +0 -57
- data/vendor/wreq/src/client/core/rt/timer.rs +0 -150
- data/vendor/wreq/src/client/core/rt/tokio.rs +0 -99
- data/vendor/wreq/src/client/core/rt.rs +0 -25
- data/vendor/wreq/src/client/core/upgrade.rs +0 -267
- data/vendor/wreq/src/client/core.rs +0 -16
- data/vendor/wreq/src/client/emulation.rs +0 -161
- data/vendor/wreq/src/client/http/client/error.rs +0 -142
- data/vendor/wreq/src/client/http/client/exec.rs +0 -29
- data/vendor/wreq/src/client/http/client/extra.rs +0 -77
- data/vendor/wreq/src/client/http/client/util.rs +0 -104
- data/vendor/wreq/src/client/http.rs +0 -1629
- data/vendor/wreq/src/client/layer/config/options.rs +0 -156
- data/vendor/wreq/src/client/layer/cookie.rs +0 -161
- data/vendor/wreq/src/hash.rs +0 -143
- data/vendor/wreq/src/tls/conn/cache.rs +0 -123
- data/vendor/wreq/src/tls/conn/cert_compression.rs +0 -125
- data/vendor/wreq/src/tls/keylog/handle.rs +0 -64
- data/vendor/wreq/src/tls/options.rs +0 -464
- /data/vendor/wreq/src/client/{http → layer}/client/lazy.rs +0 -0
- /data/vendor/wreq/src/{client/conn → conn}/proxy.rs +0 -0
- /data/vendor/wreq/src/{client/conn → conn}/verbose.rs +0 -0
data/vendor/wreq/src/tls.rs
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
//! TLS options configuration
|
|
2
2
|
//!
|
|
3
|
-
//! By default, a `Client` will make use of BoringSSL for TLS.
|
|
4
|
-
//!
|
|
5
3
|
//! - Various parts of TLS can also be configured or even disabled on the `ClientBuilder`.
|
|
6
4
|
|
|
7
|
-
pub(
|
|
8
|
-
mod keylog;
|
|
9
|
-
mod options;
|
|
10
|
-
mod x509;
|
|
5
|
+
pub(super) mod conn;
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
pub
|
|
14
|
-
|
|
7
|
+
pub mod compress;
|
|
8
|
+
pub mod keylog;
|
|
9
|
+
pub mod session;
|
|
10
|
+
pub mod trust;
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
12
|
+
use std::borrow::Cow;
|
|
13
|
+
|
|
14
|
+
/// Re-exports of TLS-related types from `btls` for public use.
|
|
15
|
+
pub use btls::ssl::{ExtensionType, KeyShare};
|
|
16
|
+
use bytes::{BufMut, Bytes, BytesMut};
|
|
17
|
+
use compress::CertificateCompressor;
|
|
21
18
|
|
|
22
19
|
/// Http extension carrying extra TLS layer information.
|
|
23
20
|
/// Made available to clients on responses when `tls_info` is set.
|
|
@@ -45,20 +42,20 @@ impl TlsInfo {
|
|
|
45
42
|
|
|
46
43
|
/// A TLS protocol version.
|
|
47
44
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
|
48
|
-
pub struct TlsVersion(ssl::SslVersion);
|
|
45
|
+
pub struct TlsVersion(btls::ssl::SslVersion);
|
|
49
46
|
|
|
50
47
|
impl TlsVersion {
|
|
51
48
|
/// Version 1.0 of the TLS protocol.
|
|
52
|
-
pub const TLS_1_0: TlsVersion = TlsVersion(ssl::SslVersion::TLS1);
|
|
49
|
+
pub const TLS_1_0: TlsVersion = TlsVersion(btls::ssl::SslVersion::TLS1);
|
|
53
50
|
|
|
54
51
|
/// Version 1.1 of the TLS protocol.
|
|
55
|
-
pub const TLS_1_1: TlsVersion = TlsVersion(ssl::SslVersion::TLS1_1);
|
|
52
|
+
pub const TLS_1_1: TlsVersion = TlsVersion(btls::ssl::SslVersion::TLS1_1);
|
|
56
53
|
|
|
57
54
|
/// Version 1.2 of the TLS protocol.
|
|
58
|
-
pub const TLS_1_2: TlsVersion = TlsVersion(ssl::SslVersion::TLS1_2);
|
|
55
|
+
pub const TLS_1_2: TlsVersion = TlsVersion(btls::ssl::SslVersion::TLS1_2);
|
|
59
56
|
|
|
60
57
|
/// Version 1.3 of the TLS protocol.
|
|
61
|
-
pub const TLS_1_3: TlsVersion = TlsVersion(ssl::SslVersion::TLS1_3);
|
|
58
|
+
pub const TLS_1_3: TlsVersion = TlsVersion(btls::ssl::SslVersion::TLS1_3);
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
/// A TLS ALPN protocol.
|
|
@@ -75,12 +72,6 @@ impl AlpnProtocol {
|
|
|
75
72
|
/// Prefer HTTP/3
|
|
76
73
|
pub const HTTP3: AlpnProtocol = AlpnProtocol(b"h3");
|
|
77
74
|
|
|
78
|
-
/// Create a new [`AlpnProtocol`] from a static byte slice.
|
|
79
|
-
#[inline]
|
|
80
|
-
pub const fn new(value: &'static [u8]) -> Self {
|
|
81
|
-
AlpnProtocol(value)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
75
|
#[inline]
|
|
85
76
|
fn encode(self) -> Bytes {
|
|
86
77
|
Self::encode_sequence(std::iter::once(&self))
|
|
@@ -99,6 +90,13 @@ impl AlpnProtocol {
|
|
|
99
90
|
}
|
|
100
91
|
}
|
|
101
92
|
|
|
93
|
+
impl PartialEq<[u8]> for AlpnProtocol {
|
|
94
|
+
#[inline]
|
|
95
|
+
fn eq(&self, other: &[u8]) -> bool {
|
|
96
|
+
self.0 == other
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
102
100
|
/// A TLS ALPS protocol.
|
|
103
101
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
|
104
102
|
pub struct AlpsProtocol(&'static [u8]);
|
|
@@ -114,6 +112,472 @@ impl AlpsProtocol {
|
|
|
114
112
|
pub const HTTP3: AlpsProtocol = AlpsProtocol(b"h3");
|
|
115
113
|
}
|
|
116
114
|
|
|
115
|
+
impl PartialEq<[u8]> for AlpsProtocol {
|
|
116
|
+
#[inline]
|
|
117
|
+
fn eq(&self, other: &[u8]) -> bool {
|
|
118
|
+
self.0 == other
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// Builder for `[`TlsOptions`]`.
|
|
123
|
+
#[must_use]
|
|
124
|
+
#[derive(Debug, Clone)]
|
|
125
|
+
pub struct TlsOptionsBuilder {
|
|
126
|
+
config: TlsOptions,
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// TLS connection configuration options.
|
|
130
|
+
///
|
|
131
|
+
/// This struct provides fine-grained control over the behavior of TLS
|
|
132
|
+
/// connections, including:
|
|
133
|
+
/// - **Protocol negotiation** (ALPN, ALPS, TLS versions)
|
|
134
|
+
/// - **Session management** (tickets, PSK, key shares)
|
|
135
|
+
/// - **Security & privacy** (OCSP, GREASE, ECH, delegated credentials)
|
|
136
|
+
/// - **Performance tuning** (record size, cipher preferences, hardware overrides)
|
|
137
|
+
///
|
|
138
|
+
/// All fields are optional or have defaults. See each field for details.
|
|
139
|
+
#[non_exhaustive]
|
|
140
|
+
#[derive(Debug, Clone)]
|
|
141
|
+
pub struct TlsOptions {
|
|
142
|
+
/// Application-Layer Protocol Negotiation ([RFC 7301](https://datatracker.ietf.org/doc/html/rfc7301)).
|
|
143
|
+
///
|
|
144
|
+
/// Specifies which application protocols (e.g., HTTP/2, HTTP/1.1) may be negotiated
|
|
145
|
+
/// over a single TLS connection.
|
|
146
|
+
///
|
|
147
|
+
/// **Default:** `Some([HTTP/2, HTTP/1.1])`
|
|
148
|
+
pub alpn_protocols: Option<Cow<'static, [AlpnProtocol]>>,
|
|
149
|
+
|
|
150
|
+
/// Application-Layer Protocol Settings (ALPS).
|
|
151
|
+
///
|
|
152
|
+
/// Enables exchanging application-layer settings during the handshake
|
|
153
|
+
/// for protocols negotiated via ALPN.
|
|
154
|
+
///
|
|
155
|
+
/// **Default:** `None`
|
|
156
|
+
pub alps_protocols: Option<Cow<'static, [AlpsProtocol]>>,
|
|
157
|
+
|
|
158
|
+
/// Whether to use an alternative ALPS codepoint for compatibility.
|
|
159
|
+
///
|
|
160
|
+
/// Useful when larger ALPS payloads are required.
|
|
161
|
+
///
|
|
162
|
+
/// **Default:** `false`
|
|
163
|
+
pub alps_use_new_codepoint: bool,
|
|
164
|
+
|
|
165
|
+
/// Enables TLS Session Tickets ([RFC 5077](https://tools.ietf.org/html/rfc5077)).
|
|
166
|
+
///
|
|
167
|
+
/// Allows session resumption without requiring server-side state.
|
|
168
|
+
///
|
|
169
|
+
/// **Default:** `true`
|
|
170
|
+
pub session_ticket: bool,
|
|
171
|
+
|
|
172
|
+
/// Minimum TLS version allowed for the connection.
|
|
173
|
+
///
|
|
174
|
+
/// **Default:** `None` (library default applied)
|
|
175
|
+
pub min_tls_version: Option<TlsVersion>,
|
|
176
|
+
|
|
177
|
+
/// Maximum TLS version allowed for the connection.
|
|
178
|
+
///
|
|
179
|
+
/// **Default:** `None` (library default applied)
|
|
180
|
+
pub max_tls_version: Option<TlsVersion>,
|
|
181
|
+
|
|
182
|
+
/// Enables Pre-Shared Key (PSK) cipher suites ([RFC 4279](https://datatracker.ietf.org/doc/html/rfc4279)).
|
|
183
|
+
///
|
|
184
|
+
/// Authentication relies on out-of-band pre-shared keys instead of certificates.
|
|
185
|
+
///
|
|
186
|
+
/// **Default:** `false`
|
|
187
|
+
pub pre_shared_key: bool,
|
|
188
|
+
|
|
189
|
+
/// Controls whether to send a GREASE Encrypted ClientHello (ECH) extension
|
|
190
|
+
/// when no supported ECH configuration is available.
|
|
191
|
+
///
|
|
192
|
+
/// GREASE prevents protocol ossification by sending unknown extensions.
|
|
193
|
+
///
|
|
194
|
+
/// **Default:** `false`
|
|
195
|
+
pub enable_ech_grease: bool,
|
|
196
|
+
|
|
197
|
+
/// Controls whether ClientHello extensions should be permuted.
|
|
198
|
+
///
|
|
199
|
+
/// **Default:** `None` (implementation default)
|
|
200
|
+
pub permute_extensions: Option<bool>,
|
|
201
|
+
|
|
202
|
+
/// Controls whether GREASE extensions ([RFC 8701](https://datatracker.ietf.org/doc/html/rfc8701))
|
|
203
|
+
/// are enabled in general.
|
|
204
|
+
///
|
|
205
|
+
/// **Default:** `None` (implementation default)
|
|
206
|
+
pub grease_enabled: Option<bool>,
|
|
207
|
+
|
|
208
|
+
/// Enables OCSP stapling for the connection.
|
|
209
|
+
///
|
|
210
|
+
/// **Default:** `false`
|
|
211
|
+
pub enable_ocsp_stapling: bool,
|
|
212
|
+
|
|
213
|
+
/// Enables Signed Certificate Timestamps (SCT).
|
|
214
|
+
///
|
|
215
|
+
/// **Default:** `false`
|
|
216
|
+
pub enable_signed_cert_timestamps: bool,
|
|
217
|
+
|
|
218
|
+
/// Sets the maximum TLS record size.
|
|
219
|
+
///
|
|
220
|
+
/// **Default:** `None`
|
|
221
|
+
pub record_size_limit: Option<u16>,
|
|
222
|
+
|
|
223
|
+
/// Whether to skip session tickets when using PSK.
|
|
224
|
+
///
|
|
225
|
+
/// **Default:** `false`
|
|
226
|
+
pub psk_skip_session_ticket: bool,
|
|
227
|
+
|
|
228
|
+
/// Whether to set specific key shares for TLS 1.3 handshakes.
|
|
229
|
+
///
|
|
230
|
+
/// **Default:** `None`
|
|
231
|
+
pub key_shares: Option<Cow<'static, [KeyShare]>>,
|
|
232
|
+
|
|
233
|
+
/// Enables PSK with (EC)DHE key establishment (`psk_dhe_ke`).
|
|
234
|
+
///
|
|
235
|
+
/// **Default:** `true`
|
|
236
|
+
pub psk_dhe_ke: bool,
|
|
237
|
+
|
|
238
|
+
/// Enables TLS renegotiation by sending the `renegotiation_info` extension.
|
|
239
|
+
///
|
|
240
|
+
/// **Default:** `true`
|
|
241
|
+
pub renegotiation: bool,
|
|
242
|
+
|
|
243
|
+
/// Delegated Credentials ([RFC 9345](https://datatracker.ietf.org/doc/html/rfc9345)).
|
|
244
|
+
///
|
|
245
|
+
/// Allows TLS 1.3 endpoints to use temporary delegated credentials
|
|
246
|
+
/// for authentication with reduced long-term key exposure.
|
|
247
|
+
///
|
|
248
|
+
/// **Default:** `None`
|
|
249
|
+
pub delegated_credentials: Option<Cow<'static, str>>,
|
|
250
|
+
|
|
251
|
+
/// List of supported elliptic curves.
|
|
252
|
+
///
|
|
253
|
+
/// **Default:** `None`
|
|
254
|
+
pub curves_list: Option<Cow<'static, str>>,
|
|
255
|
+
|
|
256
|
+
/// List of supported signature algorithms.
|
|
257
|
+
///
|
|
258
|
+
/// **Default:** `None`
|
|
259
|
+
pub sigalgs_list: Option<Cow<'static, str>>,
|
|
260
|
+
|
|
261
|
+
/// Cipher suite configuration string.
|
|
262
|
+
///
|
|
263
|
+
/// Uses BoringSSL's mini-language to select, enable, and prioritize ciphers.
|
|
264
|
+
///
|
|
265
|
+
/// **Default:** `None`
|
|
266
|
+
pub cipher_list: Option<Cow<'static, str>>,
|
|
267
|
+
|
|
268
|
+
/// Sets whether to preserve the TLS 1.3 cipher list as configured by [`Self::cipher_list`].
|
|
269
|
+
///
|
|
270
|
+
/// **Default:** `None`
|
|
271
|
+
pub preserve_tls13_cipher_list: Option<bool>,
|
|
272
|
+
|
|
273
|
+
/// Supported certificate compression algorithms ([RFC 8879](https://datatracker.ietf.org/doc/html/rfc8879)).
|
|
274
|
+
///
|
|
275
|
+
/// **Default:** `None`
|
|
276
|
+
pub certificate_compressors: Option<Cow<'static, [&'static dyn CertificateCompressor]>>,
|
|
277
|
+
|
|
278
|
+
/// Supported TLS extensions, used for extension ordering/permutation.
|
|
279
|
+
///
|
|
280
|
+
/// **Default:** `None`
|
|
281
|
+
pub extension_permutation: Option<Cow<'static, [ExtensionType]>>,
|
|
282
|
+
|
|
283
|
+
/// Overrides AES hardware acceleration.
|
|
284
|
+
///
|
|
285
|
+
/// **Default:** `None`
|
|
286
|
+
pub aes_hw_override: Option<bool>,
|
|
287
|
+
|
|
288
|
+
/// Overrides the random AES hardware acceleration.
|
|
289
|
+
///
|
|
290
|
+
/// **Default:** `false`
|
|
291
|
+
pub random_aes_hw_override: bool,
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
impl TlsOptionsBuilder {
|
|
295
|
+
/// Sets the ALPN protocols to use.
|
|
296
|
+
#[inline]
|
|
297
|
+
pub fn alpn_protocols<I>(mut self, alpn: I) -> Self
|
|
298
|
+
where
|
|
299
|
+
I: IntoIterator<Item = AlpnProtocol>,
|
|
300
|
+
{
|
|
301
|
+
self.config.alpn_protocols = Some(Cow::Owned(alpn.into_iter().collect()));
|
|
302
|
+
self
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/// Sets the ALPS protocols to use.
|
|
306
|
+
#[inline]
|
|
307
|
+
pub fn alps_protocols<I>(mut self, alps: I) -> Self
|
|
308
|
+
where
|
|
309
|
+
I: IntoIterator<Item = AlpsProtocol>,
|
|
310
|
+
{
|
|
311
|
+
self.config.alps_protocols = Some(Cow::Owned(alps.into_iter().collect()));
|
|
312
|
+
self
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/// Sets whether to use a new codepoint for ALPS.
|
|
316
|
+
#[inline]
|
|
317
|
+
pub fn alps_use_new_codepoint(mut self, enabled: bool) -> Self {
|
|
318
|
+
self.config.alps_use_new_codepoint = enabled;
|
|
319
|
+
self
|
|
320
|
+
}
|
|
321
|
+
/// Sets the session ticket flag.
|
|
322
|
+
#[inline]
|
|
323
|
+
pub fn session_ticket(mut self, enabled: bool) -> Self {
|
|
324
|
+
self.config.session_ticket = enabled;
|
|
325
|
+
self
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/// Sets the minimum TLS version to use.
|
|
329
|
+
#[inline]
|
|
330
|
+
pub fn min_tls_version<T>(mut self, version: T) -> Self
|
|
331
|
+
where
|
|
332
|
+
T: Into<Option<TlsVersion>>,
|
|
333
|
+
{
|
|
334
|
+
self.config.min_tls_version = version.into();
|
|
335
|
+
self
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/// Sets the maximum TLS version to use.
|
|
339
|
+
#[inline]
|
|
340
|
+
pub fn max_tls_version<T>(mut self, version: T) -> Self
|
|
341
|
+
where
|
|
342
|
+
T: Into<Option<TlsVersion>>,
|
|
343
|
+
{
|
|
344
|
+
self.config.max_tls_version = version.into();
|
|
345
|
+
self
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/// Sets the pre-shared key flag.
|
|
349
|
+
#[inline]
|
|
350
|
+
pub fn pre_shared_key(mut self, enabled: bool) -> Self {
|
|
351
|
+
self.config.pre_shared_key = enabled;
|
|
352
|
+
self
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/// Sets the GREASE ECH extension flag.
|
|
356
|
+
#[inline]
|
|
357
|
+
pub fn enable_ech_grease(mut self, enabled: bool) -> Self {
|
|
358
|
+
self.config.enable_ech_grease = enabled;
|
|
359
|
+
self
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/// Sets whether to permute ClientHello extensions.
|
|
363
|
+
#[inline]
|
|
364
|
+
pub fn permute_extensions<T>(mut self, permute: T) -> Self
|
|
365
|
+
where
|
|
366
|
+
T: Into<Option<bool>>,
|
|
367
|
+
{
|
|
368
|
+
self.config.permute_extensions = permute.into();
|
|
369
|
+
self
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/// Sets the GREASE enabled flag.
|
|
373
|
+
#[inline]
|
|
374
|
+
pub fn grease_enabled<T>(mut self, enabled: T) -> Self
|
|
375
|
+
where
|
|
376
|
+
T: Into<Option<bool>>,
|
|
377
|
+
{
|
|
378
|
+
self.config.grease_enabled = enabled.into();
|
|
379
|
+
self
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/// Sets the OCSP stapling flag.
|
|
383
|
+
#[inline]
|
|
384
|
+
pub fn enable_ocsp_stapling(mut self, enabled: bool) -> Self {
|
|
385
|
+
self.config.enable_ocsp_stapling = enabled;
|
|
386
|
+
self
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/// Sets the signed certificate timestamps flag.
|
|
390
|
+
#[inline]
|
|
391
|
+
pub fn enable_signed_cert_timestamps(mut self, enabled: bool) -> Self {
|
|
392
|
+
self.config.enable_signed_cert_timestamps = enabled;
|
|
393
|
+
self
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/// Sets the record size limit.
|
|
397
|
+
#[inline]
|
|
398
|
+
pub fn record_size_limit<U: Into<Option<u16>>>(mut self, limit: U) -> Self {
|
|
399
|
+
self.config.record_size_limit = limit.into();
|
|
400
|
+
self
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/// Sets the PSK skip session ticket flag.
|
|
404
|
+
#[inline]
|
|
405
|
+
pub fn psk_skip_session_ticket(mut self, skip: bool) -> Self {
|
|
406
|
+
self.config.psk_skip_session_ticket = skip;
|
|
407
|
+
self
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/// Sets the PSK DHE key establishment flag.
|
|
411
|
+
#[inline]
|
|
412
|
+
pub fn psk_dhe_ke(mut self, enabled: bool) -> Self {
|
|
413
|
+
self.config.psk_dhe_ke = enabled;
|
|
414
|
+
self
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/// Sets the renegotiation flag.
|
|
418
|
+
#[inline]
|
|
419
|
+
pub fn renegotiation(mut self, enabled: bool) -> Self {
|
|
420
|
+
self.config.renegotiation = enabled;
|
|
421
|
+
self
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/// Sets the delegated credentials.
|
|
425
|
+
#[inline]
|
|
426
|
+
pub fn delegated_credentials<T>(mut self, creds: T) -> Self
|
|
427
|
+
where
|
|
428
|
+
T: Into<Cow<'static, str>>,
|
|
429
|
+
{
|
|
430
|
+
self.config.delegated_credentials = Some(creds.into());
|
|
431
|
+
self
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/// Sets the client key shares to be used in the TLS 1.3 handshake.
|
|
435
|
+
#[inline]
|
|
436
|
+
pub fn key_shares<T>(mut self, key_shares: T) -> Self
|
|
437
|
+
where
|
|
438
|
+
T: Into<Cow<'static, [KeyShare]>>,
|
|
439
|
+
{
|
|
440
|
+
self.config.key_shares = Some(key_shares.into());
|
|
441
|
+
self
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/// Sets the supported curves list.
|
|
445
|
+
#[inline]
|
|
446
|
+
pub fn curves_list<T>(mut self, curves: T) -> Self
|
|
447
|
+
where
|
|
448
|
+
T: Into<Cow<'static, str>>,
|
|
449
|
+
{
|
|
450
|
+
self.config.curves_list = Some(curves.into());
|
|
451
|
+
self
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/// Sets the cipher list.
|
|
455
|
+
#[inline]
|
|
456
|
+
pub fn cipher_list<T>(mut self, ciphers: T) -> Self
|
|
457
|
+
where
|
|
458
|
+
T: Into<Cow<'static, str>>,
|
|
459
|
+
{
|
|
460
|
+
self.config.cipher_list = Some(ciphers.into());
|
|
461
|
+
self
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/// Sets the supported signature algorithms.
|
|
465
|
+
#[inline]
|
|
466
|
+
pub fn sigalgs_list<T>(mut self, sigalgs: T) -> Self
|
|
467
|
+
where
|
|
468
|
+
T: Into<Cow<'static, str>>,
|
|
469
|
+
{
|
|
470
|
+
self.config.sigalgs_list = Some(sigalgs.into());
|
|
471
|
+
self
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/// Sets the certificate compression algorithms.
|
|
475
|
+
#[inline]
|
|
476
|
+
pub fn certificate_compressors<T>(mut self, algs: T) -> Self
|
|
477
|
+
where
|
|
478
|
+
T: Into<Cow<'static, [&'static dyn CertificateCompressor]>>,
|
|
479
|
+
{
|
|
480
|
+
self.config.certificate_compressors = Some(algs.into());
|
|
481
|
+
self
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/// Sets the extension permutation.
|
|
485
|
+
#[inline]
|
|
486
|
+
pub fn extension_permutation<T>(mut self, permutation: T) -> Self
|
|
487
|
+
where
|
|
488
|
+
T: Into<Cow<'static, [ExtensionType]>>,
|
|
489
|
+
{
|
|
490
|
+
self.config.extension_permutation = Some(permutation.into());
|
|
491
|
+
self
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/// Sets the AES hardware override flag.
|
|
495
|
+
#[inline]
|
|
496
|
+
pub fn aes_hw_override<T>(mut self, enabled: T) -> Self
|
|
497
|
+
where
|
|
498
|
+
T: Into<Option<bool>>,
|
|
499
|
+
{
|
|
500
|
+
self.config.aes_hw_override = enabled.into();
|
|
501
|
+
self
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/// Sets the random AES hardware override flag.
|
|
505
|
+
#[inline]
|
|
506
|
+
pub fn random_aes_hw_override(mut self, enabled: bool) -> Self {
|
|
507
|
+
self.config.random_aes_hw_override = enabled;
|
|
508
|
+
self
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/// Sets whether to preserve the TLS 1.3 cipher list as configured by [`Self::cipher_list`].
|
|
512
|
+
///
|
|
513
|
+
/// By default, BoringSSL does not preserve the TLS 1.3 cipher list. When this option is
|
|
514
|
+
/// disabled (the default), BoringSSL uses its internal default TLS 1.3 cipher suites in its
|
|
515
|
+
/// default order, regardless of what is set via [`Self::cipher_list`].
|
|
516
|
+
///
|
|
517
|
+
/// When enabled, this option ensures that the TLS 1.3 cipher suites explicitly set via
|
|
518
|
+
/// [`Self::cipher_list`] are retained in their original order, without being reordered or
|
|
519
|
+
/// modified by BoringSSL's internal logic. This is useful for maintaining specific cipher suite
|
|
520
|
+
/// priorities for TLS 1.3. Note that if [`Self::cipher_list`] does not include any TLS 1.3
|
|
521
|
+
/// cipher suites, BoringSSL will still fall back to its default TLS 1.3 cipher suites and
|
|
522
|
+
/// order.
|
|
523
|
+
#[inline]
|
|
524
|
+
pub fn preserve_tls13_cipher_list<T>(mut self, enabled: T) -> Self
|
|
525
|
+
where
|
|
526
|
+
T: Into<Option<bool>>,
|
|
527
|
+
{
|
|
528
|
+
self.config.preserve_tls13_cipher_list = enabled.into();
|
|
529
|
+
self
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/// Builds the `TlsOptions` from the builder.
|
|
533
|
+
#[inline]
|
|
534
|
+
pub fn build(self) -> TlsOptions {
|
|
535
|
+
self.config
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
impl TlsOptions {
|
|
540
|
+
/// Creates a new `TlsOptionsBuilder` instance.
|
|
541
|
+
pub fn builder() -> TlsOptionsBuilder {
|
|
542
|
+
TlsOptionsBuilder {
|
|
543
|
+
config: TlsOptions::default(),
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
impl Default for TlsOptions {
|
|
549
|
+
fn default() -> Self {
|
|
550
|
+
TlsOptions {
|
|
551
|
+
alpn_protocols: Some(Cow::Borrowed(&[AlpnProtocol::HTTP2, AlpnProtocol::HTTP1])),
|
|
552
|
+
alps_protocols: None,
|
|
553
|
+
alps_use_new_codepoint: false,
|
|
554
|
+
session_ticket: true,
|
|
555
|
+
min_tls_version: None,
|
|
556
|
+
max_tls_version: None,
|
|
557
|
+
pre_shared_key: false,
|
|
558
|
+
enable_ech_grease: false,
|
|
559
|
+
permute_extensions: None,
|
|
560
|
+
grease_enabled: None,
|
|
561
|
+
enable_ocsp_stapling: false,
|
|
562
|
+
enable_signed_cert_timestamps: false,
|
|
563
|
+
record_size_limit: None,
|
|
564
|
+
psk_skip_session_ticket: false,
|
|
565
|
+
key_shares: None,
|
|
566
|
+
psk_dhe_ke: true,
|
|
567
|
+
renegotiation: true,
|
|
568
|
+
delegated_credentials: None,
|
|
569
|
+
curves_list: None,
|
|
570
|
+
cipher_list: None,
|
|
571
|
+
sigalgs_list: None,
|
|
572
|
+
certificate_compressors: None,
|
|
573
|
+
extension_permutation: None,
|
|
574
|
+
aes_hw_override: None,
|
|
575
|
+
preserve_tls13_cipher_list: None,
|
|
576
|
+
random_aes_hw_override: false,
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
117
581
|
#[cfg(test)]
|
|
118
582
|
mod tests {
|
|
119
583
|
use super::*;
|
data/vendor/wreq/src/trace.rs
CHANGED
|
@@ -20,18 +20,6 @@ macro_rules! trace {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
macro_rules! trace_span {
|
|
24
|
-
($($arg:tt)*) => {
|
|
25
|
-
{
|
|
26
|
-
#[cfg(feature = "tracing")]
|
|
27
|
-
{
|
|
28
|
-
let _span = ::tracing::trace_span!($($arg)+);
|
|
29
|
-
let _ = _span.entered();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
23
|
macro_rules! warn {
|
|
36
24
|
($($arg:tt)*) => {
|
|
37
25
|
{
|
data/vendor/wreq/src/util.rs
CHANGED
data/vendor/wreq/tests/badssl.rs
CHANGED
|
@@ -2,7 +2,7 @@ use std::time::Duration;
|
|
|
2
2
|
|
|
3
3
|
use wreq::{
|
|
4
4
|
Client,
|
|
5
|
-
tls::{AlpsProtocol,
|
|
5
|
+
tls::{AlpsProtocol, TlsInfo, TlsOptions, TlsVersion, trust::CertStore},
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
macro_rules! join {
|
|
@@ -32,7 +32,7 @@ async fn test_badssl_modern() {
|
|
|
32
32
|
#[tokio::test]
|
|
33
33
|
async fn test_badssl_self_signed() {
|
|
34
34
|
let text = Client::builder()
|
|
35
|
-
.
|
|
35
|
+
.tls_cert_verification(false)
|
|
36
36
|
.connect_timeout(Duration::from_secs(360))
|
|
37
37
|
.no_proxy()
|
|
38
38
|
.build()
|
|
@@ -70,8 +70,8 @@ async fn test_3des_support() -> wreq::Result<()> {
|
|
|
70
70
|
|
|
71
71
|
// Create a client with the TLS options
|
|
72
72
|
let client = Client::builder()
|
|
73
|
-
.
|
|
74
|
-
.
|
|
73
|
+
.tls_options(tls_options)
|
|
74
|
+
.tls_cert_verification(false)
|
|
75
75
|
.connect_timeout(Duration::from_secs(360))
|
|
76
76
|
.build()?;
|
|
77
77
|
|
|
@@ -103,8 +103,8 @@ async fn test_firefox_7x_100_cipher() -> wreq::Result<()> {
|
|
|
103
103
|
|
|
104
104
|
// Create a client with the TLS options
|
|
105
105
|
let client = Client::builder()
|
|
106
|
-
.
|
|
107
|
-
.
|
|
106
|
+
.tls_options(tls_options)
|
|
107
|
+
.tls_cert_verification(false)
|
|
108
108
|
.connect_timeout(Duration::from_secs(360))
|
|
109
109
|
.build()?;
|
|
110
110
|
|
|
@@ -131,7 +131,7 @@ async fn test_alps_new_endpoint() -> wreq::Result<()> {
|
|
|
131
131
|
.build();
|
|
132
132
|
|
|
133
133
|
let client = Client::builder()
|
|
134
|
-
.
|
|
134
|
+
.tls_options(tls_options)
|
|
135
135
|
.connect_timeout(Duration::from_secs(360))
|
|
136
136
|
.build()?;
|
|
137
137
|
|
|
@@ -174,7 +174,7 @@ async fn test_aes_hw_override() -> wreq::Result<()> {
|
|
|
174
174
|
|
|
175
175
|
// Create a client with the TLS options
|
|
176
176
|
let client = Client::builder()
|
|
177
|
-
.
|
|
177
|
+
.tls_options(tls_options)
|
|
178
178
|
.connect_timeout(Duration::from_secs(360))
|
|
179
179
|
.build()?;
|
|
180
180
|
|
|
@@ -188,7 +188,7 @@ async fn test_aes_hw_override() -> wreq::Result<()> {
|
|
|
188
188
|
#[tokio::test]
|
|
189
189
|
async fn test_tls_self_signed_cert() {
|
|
190
190
|
let client = Client::builder()
|
|
191
|
-
.
|
|
191
|
+
.tls_cert_verification(false)
|
|
192
192
|
.connect_timeout(Duration::from_secs(360))
|
|
193
193
|
.tls_info(true)
|
|
194
194
|
.build()
|
|
@@ -212,7 +212,7 @@ async fn test_tls_self_signed_cert() {
|
|
|
212
212
|
.unwrap();
|
|
213
213
|
|
|
214
214
|
let client = Client::builder()
|
|
215
|
-
.
|
|
215
|
+
.tls_cert_store(self_signed_cert_store)
|
|
216
216
|
.build()
|
|
217
217
|
.unwrap();
|
|
218
218
|
|
data/vendor/wreq/tests/client.rs
CHANGED
|
@@ -727,10 +727,7 @@ async fn http1_only() {
|
|
|
727
727
|
|
|
728
728
|
assert_eq!(resp.version(), wreq::Version::HTTP_11);
|
|
729
729
|
|
|
730
|
-
let resp =
|
|
731
|
-
.build()
|
|
732
|
-
.unwrap()
|
|
733
|
-
.get(format!("http://{}", server.addr()))
|
|
730
|
+
let resp = wreq::get(format!("http://{}", server.addr()))
|
|
734
731
|
.version(Version::HTTP_11)
|
|
735
732
|
.send()
|
|
736
733
|
.await
|
|
@@ -754,10 +751,7 @@ async fn http2_only() {
|
|
|
754
751
|
|
|
755
752
|
assert_eq!(resp.version(), wreq::Version::HTTP_2);
|
|
756
753
|
|
|
757
|
-
let resp =
|
|
758
|
-
.build()
|
|
759
|
-
.unwrap()
|
|
760
|
-
.get(format!("http://{}", server.addr()))
|
|
754
|
+
let resp = wreq::get(format!("http://{}", server.addr()))
|
|
761
755
|
.version(Version::HTTP_2)
|
|
762
756
|
.send()
|
|
763
757
|
.await
|
|
@@ -809,7 +803,7 @@ async fn http1_send_case_sensitive_headers() {
|
|
|
809
803
|
orig_headers.insert("X-custom-header");
|
|
810
804
|
orig_headers.insert("Host");
|
|
811
805
|
|
|
812
|
-
let resp = wreq::get("https://tls.
|
|
806
|
+
let resp = wreq::get("https://tls.browserleaks.com")
|
|
813
807
|
.header("X-Custom-Header", "value")
|
|
814
808
|
.orig_headers(orig_headers)
|
|
815
809
|
.version(Version::HTTP_11)
|