File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ homepage = "https://github.com/ctz/hyper-rustls"
10
10
repository = " https://github.com/ctz/hyper-rustls"
11
11
12
12
[dependencies ]
13
- log = " 0.4.4"
13
+ log = { version = " 0.4.4" , optional = true }
14
14
http = " 0.2"
15
15
hyper = { version = " 0.14" , default-features = false , features = [" client" ] }
16
- rustls = " 0.20"
16
+ rustls = { version = " 0.20" , default-features = false }
17
17
rustls-native-certs = { version = " 0.6" , optional = true }
18
18
tokio = " 1.0"
19
- tokio-rustls = " 0.23"
19
+ tokio-rustls = { version = " 0.23" , default-features = false }
20
20
webpki-roots = { version = " 0.22" , optional = true }
21
21
22
22
[dev-dependencies ]
@@ -27,12 +27,14 @@ futures-util = { version = "0.3.1", default-features = false }
27
27
rustls-pemfile = " 0.2.1"
28
28
29
29
[features ]
30
- default = [" native-tokio" , " http1" ]
30
+ default = [" native-tokio" , " http1" , " tls12 " , " logging " ]
31
31
http1 = [" hyper/http1" ]
32
32
http2 = [" hyper/http2" ]
33
33
webpki-tokio = [" tokio-runtime" , " webpki-roots" ]
34
34
native-tokio = [" tokio-runtime" , " rustls-native-certs" ]
35
35
tokio-runtime = [" hyper/runtime" ]
36
+ tls12 = [" tokio-rustls/tls12" , " rustls/tls12" ]
37
+ logging = [" log" , " tokio-rustls/logging" , " rustls/logging" ]
36
38
37
39
[[example ]]
38
40
name = " client"
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub trait ConfigBuilderExt {
21
21
impl ConfigBuilderExt for ConfigBuilder < ClientConfig , WantsVerifier > {
22
22
#[ cfg( feature = "rustls-native-certs" ) ]
23
23
#[ cfg_attr( docsrs, doc( cfg( feature = "rustls-native-certs" ) ) ) ]
24
+ #[ cfg_attr( not( feature = "logging" ) , allow( unused_variables) ) ]
24
25
fn with_native_roots ( self ) -> ClientConfig {
25
26
let mut roots = rustls:: RootCertStore :: empty ( ) ;
26
27
let mut valid_count = 0 ;
@@ -32,13 +33,13 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
32
33
match roots. add ( & cert) {
33
34
Ok ( _) => valid_count += 1 ,
34
35
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) ;
37
38
invalid_count += 1
38
39
}
39
40
}
40
41
}
41
- log:: debug!(
42
+ crate :: log:: debug!(
42
43
"with_native_roots processed {} valid and {} invalid certs" ,
43
44
valid_count, invalid_count
44
45
) ;
Original file line number Diff line number Diff line change @@ -34,6 +34,18 @@ mod config;
34
34
mod connector;
35
35
mod stream;
36
36
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
+
37
49
pub use crate :: config:: ConfigBuilderExt ;
38
50
pub use crate :: connector:: builder:: ConnectorBuilder as HttpsConnectorBuilder ;
39
51
pub use crate :: connector:: HttpsConnector ;
You can’t perform that action at this time.
0 commit comments