Skip to content

Commit 05f5a0b

Browse files
committed
Expose and forward rustls default features
tls12 and logging are rustls features we enable by default, as does rustls, exposing them explicitly allows users to disable them by disabling hyper-rustls default features.
1 parent bc8023b commit 05f5a0b

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ homepage = "https://github.com/ctz/hyper-rustls"
1010
repository = "https://github.com/ctz/hyper-rustls"
1111

1212
[dependencies]
13-
log = "0.4.4"
13+
log = { version = "0.4.4", optional = true }
1414
http = "0.2"
1515
hyper = { version = "0.14", default-features = false, features = ["client"] }
16-
rustls = "0.20"
16+
rustls = { version = "0.20", default-features = false }
1717
rustls-native-certs = { version = "0.6", optional = true }
1818
tokio = "1.0"
19-
tokio-rustls = "0.23"
19+
tokio-rustls = { version = "0.23", default-features = false }
2020
webpki-roots = { version = "0.22", optional = true }
2121

2222
[dev-dependencies]
@@ -27,12 +27,14 @@ futures-util = { version = "0.3.1", default-features = false }
2727
rustls-pemfile = "0.2.1"
2828

2929
[features]
30-
default = ["native-tokio", "http1"]
30+
default = ["native-tokio", "http1", "tls12", "logging"]
3131
http1 = ["hyper/http1"]
3232
http2 = ["hyper/http2"]
3333
webpki-tokio = ["tokio-runtime", "webpki-roots"]
3434
native-tokio = ["tokio-runtime", "rustls-native-certs"]
3535
tokio-runtime = ["hyper/runtime"]
36+
tls12 = ["tokio-rustls/tls12", "rustls/tls12"]
37+
logging = ["log", "tokio-rustls/logging", "rustls/logging"]
3638

3739
[[example]]
3840
name = "client"

src/config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub trait ConfigBuilderExt {
2121
impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
2222
#[cfg(feature = "rustls-native-certs")]
2323
#[cfg_attr(docsrs, doc(cfg(feature = "rustls-native-certs")))]
24+
#[cfg_attr(not(feature = "logging"), allow(unused_variables))]
2425
fn with_native_roots(self) -> ClientConfig {
2526
let mut roots = rustls::RootCertStore::empty();
2627
let mut valid_count = 0;
@@ -32,13 +33,13 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
3233
match roots.add(&cert) {
3334
Ok(_) => valid_count += 1,
3435
Err(err) => {
35-
log::trace!("invalid cert der {:?}", cert.0);
36-
log::debug!("certificate parsing failed: {:?}", err);
36+
crate::log::trace!("invalid cert der {:?}", cert.0);
37+
crate::log::debug!("certificate parsing failed: {:?}", err);
3738
invalid_count += 1
3839
}
3940
}
4041
}
41-
log::debug!(
42+
crate::log::debug!(
4243
"with_native_roots processed {} valid and {} invalid certs",
4344
valid_count, invalid_count
4445
);

src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ mod config;
3434
mod connector;
3535
mod stream;
3636

37+
#[cfg(feature = "logging")]
38+
mod log {
39+
pub use log::{debug, trace};
40+
}
41+
42+
#[cfg(not(feature = "logging"))]
43+
mod log {
44+
macro_rules! trace ( ($($tt:tt)*) => {{}} );
45+
macro_rules! debug ( ($($tt:tt)*) => {{}} );
46+
pub(crate) use {debug, trace};
47+
}
48+
3749
pub use crate::config::ConfigBuilderExt;
3850
pub use crate::connector::builder::ConnectorBuilder as HttpsConnectorBuilder;
3951
pub use crate::connector::HttpsConnector;

0 commit comments

Comments
 (0)