1
+ use rustls:: client:: WantsTransparencyPolicyOrClientCert ;
1
2
use rustls:: { ClientConfig , ConfigBuilder , WantsVerifier } ;
2
3
3
4
/// Methods for configuring roots
@@ -9,20 +10,20 @@ pub trait ConfigBuilderExt {
9
10
/// rustls-native-certs
10
11
#[ cfg( feature = "rustls-native-certs" ) ]
11
12
#[ cfg_attr( docsrs, doc( cfg( feature = "rustls-native-certs" ) ) ) ]
12
- fn with_native_roots ( self ) -> ClientConfig ;
13
+ fn with_native_roots ( self ) -> ConfigBuilder < ClientConfig , WantsTransparencyPolicyOrClientCert > ;
13
14
14
15
/// This configures the webpki roots, which are Mozilla's set of
15
16
/// trusted roots as packaged by webpki-roots.
16
17
#[ cfg( feature = "webpki-roots" ) ]
17
18
#[ cfg_attr( docsrs, doc( cfg( feature = "webpki-roots" ) ) ) ]
18
- fn with_webpki_roots ( self ) -> ClientConfig ;
19
+ fn with_webpki_roots ( self ) -> ConfigBuilder < ClientConfig , WantsTransparencyPolicyOrClientCert > ;
19
20
}
20
21
21
22
impl ConfigBuilderExt for ConfigBuilder < ClientConfig , WantsVerifier > {
22
23
#[ cfg( feature = "rustls-native-certs" ) ]
23
24
#[ cfg_attr( docsrs, doc( cfg( feature = "rustls-native-certs" ) ) ) ]
24
25
#[ cfg_attr( not( feature = "logging" ) , allow( unused_variables) ) ]
25
- fn with_native_roots ( self ) -> ClientConfig {
26
+ fn with_native_roots ( self ) -> ConfigBuilder < ClientConfig , WantsTransparencyPolicyOrClientCert > {
26
27
let mut roots = rustls:: RootCertStore :: empty ( ) ;
27
28
let mut valid_count = 0 ;
28
29
let mut invalid_count = 0 ;
@@ -41,16 +42,17 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
41
42
}
42
43
crate :: log:: debug!(
43
44
"with_native_roots processed {} valid and {} invalid certs" ,
44
- valid_count, invalid_count
45
+ valid_count,
46
+ invalid_count
45
47
) ;
46
48
assert ! ( !roots. is_empty( ) , "no CA certificates found" ) ;
47
49
48
- self . with_root_certificates ( roots) . with_no_client_auth ( )
50
+ self . with_root_certificates ( roots)
49
51
}
50
52
51
53
#[ cfg( feature = "webpki-roots" ) ]
52
54
#[ cfg_attr( docsrs, doc( cfg( feature = "webpki-roots" ) ) ) ]
53
- fn with_webpki_roots ( self ) -> ClientConfig {
55
+ fn with_webpki_roots ( self ) -> ConfigBuilder < ClientConfig , WantsTransparencyPolicyOrClientCert > {
54
56
let mut roots = rustls:: RootCertStore :: empty ( ) ;
55
57
roots. add_server_trust_anchors ( webpki_roots:: TLS_SERVER_ROOTS . 0 . iter ( ) . map ( |ta| {
56
58
rustls:: OwnedTrustAnchor :: from_subject_spki_name_constraints (
@@ -59,6 +61,6 @@ impl ConfigBuilderExt for ConfigBuilder<ClientConfig, WantsVerifier> {
59
61
ta. name_constraints ,
60
62
)
61
63
} ) ) ;
62
- self . with_root_certificates ( roots) . with_no_client_auth ( )
64
+ self . with_root_certificates ( roots)
63
65
}
64
66
}
0 commit comments