1
- #[ cfg( any( feature = "rustls-native-certs" , feature = "webpki-roots" ) ) ]
1
+ #[ cfg( feature = "rustls-platform-verifier" ) ]
2
+ use std:: sync:: Arc ;
3
+
4
+ #[ cfg( any(
5
+ feature = "rustls-platform-verifier" ,
6
+ feature = "rustls-native-certs" ,
7
+ feature = "webpki-roots"
8
+ ) ) ]
2
9
use rustls:: client:: WantsClientCert ;
3
10
use rustls:: { ClientConfig , ConfigBuilder , WantsVerifier } ;
4
11
@@ -7,6 +14,14 @@ use rustls::{ClientConfig, ConfigBuilder, WantsVerifier};
7
14
/// This adds methods (gated by crate features) for easily configuring
8
15
/// TLS server roots a rustls ClientConfig will trust.
9
16
pub trait ConfigBuilderExt {
17
+ /// Use the platform's native verifier to verify server certificates.
18
+ ///
19
+ /// See the documentation for [rustls-platform-verifier] for more details.
20
+ ///
21
+ /// [rustls-platform-verifier]: https://docs.rs/rustls-platform-verifier
22
+ #[ cfg( feature = "rustls-platform-verifier" ) ]
23
+ fn with_platform_verifier ( self ) -> ConfigBuilder < ClientConfig , WantsClientCert > ;
24
+
10
25
/// This configures the platform's trusted certs, as implemented by
11
26
/// rustls-native-certs
12
27
///
@@ -22,6 +37,14 @@ pub trait ConfigBuilderExt {
22
37
}
23
38
24
39
impl ConfigBuilderExt for ConfigBuilder < ClientConfig , WantsVerifier > {
40
+ #[ cfg( feature = "rustls-platform-verifier" ) ]
41
+ fn with_platform_verifier ( self ) -> ConfigBuilder < ClientConfig , WantsClientCert > {
42
+ self . dangerous ( )
43
+ . with_custom_certificate_verifier ( Arc :: new (
44
+ rustls_platform_verifier:: Verifier :: default ( ) ,
45
+ ) )
46
+ }
47
+
25
48
#[ cfg( feature = "rustls-native-certs" ) ]
26
49
#[ cfg_attr( not( feature = "logging" ) , allow( unused_variables) ) ]
27
50
fn with_native_roots ( self ) -> std:: io:: Result < ConfigBuilder < ClientConfig , WantsClientCert > > {
0 commit comments