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+ ) ) ]
29use rustls:: client:: WantsClientCert ;
310use rustls:: { ClientConfig , ConfigBuilder , WantsVerifier } ;
411
@@ -7,6 +14,14 @@ use rustls::{ClientConfig, ConfigBuilder, WantsVerifier};
714/// This adds methods (gated by crate features) for easily configuring
815/// TLS server roots a rustls ClientConfig will trust.
916pub 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+
1025 /// This configures the platform's trusted certs, as implemented by
1126 /// rustls-native-certs
1227 ///
@@ -22,6 +37,14 @@ pub trait ConfigBuilderExt {
2237}
2338
2439impl 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+
2548 #[ cfg( feature = "rustls-native-certs" ) ]
2649 #[ cfg_attr( not( feature = "logging" ) , allow( unused_variables) ) ]
2750 fn with_native_roots ( self ) -> std:: io:: Result < ConfigBuilder < ClientConfig , WantsClientCert > > {
0 commit comments