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
62
63
64
65
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
use crate::{new_trust_dns_http_connector, TrustDnsHttpConnector};
#[cfg(all(not(feature = "rustls-http1"), not(feature = "rustls-http2")))]
compile_error!("Either the rustls-http1 or the rustls-http2 feature must be enabled");
#[cfg_attr(
docsrs,
doc(cfg(any(feature = "rustls-native", feature = "rustls-webpki")))
)]
pub type RustlsHttpsConnector = HttpsConnector<TrustDnsHttpConnector>;
#[cfg(feature = "rustls-native")]
#[must_use]
pub fn new_rustls_native_https_connector() -> RustlsHttpsConnector {
let mut http_connector = new_trust_dns_http_connector();
http_connector.enforce_http(false);
let builder = HttpsConnectorBuilder::new().with_native_roots();
#[cfg(feature = "https-only")]
let builder = builder.https_only();
#[cfg(not(feature = "https-only"))]
let builder = builder.https_or_http();
#[cfg(feature = "rustls-http1")]
let builder = builder.enable_http1();
#[cfg(feature = "rustls-http2")]
let builder = builder.enable_http2();
builder.wrap_connector(http_connector)
}
#[cfg(feature = "rustls-webpki")]
#[must_use]
pub fn new_rustls_webpki_https_connector() -> RustlsHttpsConnector {
let mut http_connector = new_trust_dns_http_connector();
http_connector.enforce_http(false);
let builder = HttpsConnectorBuilder::new().with_webpki_roots();
#[cfg(feature = "https-only")]
let builder = builder.https_only();
#[cfg(not(feature = "https-only"))]
let builder = builder.https_or_http();
#[cfg(feature = "rustls-http1")]
let builder = builder.enable_http1();
#[cfg(feature = "rustls-http2")]
let builder = builder.enable_http2();
builder.wrap_connector(http_connector)
}