1
1
use std:: sync:: Arc ;
2
2
3
3
use hyper_util:: client:: legacy:: connect:: HttpConnector ;
4
- #[ cfg( any( feature = "rustls-native-certs" , feature = "webpki-roots" ) ) ]
4
+ #[ cfg( any(
5
+ feature = "rustls-native-certs" ,
6
+ feature = "rustls-platform-verifier" ,
7
+ feature = "webpki-roots"
8
+ ) ) ]
5
9
use rustls:: crypto:: CryptoProvider ;
6
10
use rustls:: ClientConfig ;
7
11
@@ -61,7 +65,8 @@ impl ConnectorBuilder<WantsTlsConfig> {
61
65
ConnectorBuilder ( WantsSchemes { tls_config : config } )
62
66
}
63
67
64
- /// Use rustls' default crypto provider and other defaults, and the platform verifier
68
+ /// Shorthand for using rustls' default crypto provider and other defaults, and
69
+ /// the platform verifier.
65
70
///
66
71
/// See [`ConfigBuilderExt::with_platform_verifier()`].
67
72
#[ cfg( all(
@@ -76,6 +81,23 @@ impl ConnectorBuilder<WantsTlsConfig> {
76
81
)
77
82
}
78
83
84
+ /// Shorthand for using a custom [`CryptoProvider`] and the platform verifier.
85
+ ///
86
+ /// See [`ConfigBuilderExt::with_platform_verifier()`].
87
+ #[ cfg( feature = "rustls-platform-verifier" ) ]
88
+ pub fn with_provider_and_platform_verifier (
89
+ self ,
90
+ provider : CryptoProvider ,
91
+ ) -> std:: io:: Result < ConnectorBuilder < WantsSchemes > > {
92
+ Ok ( self . with_tls_config (
93
+ ClientConfig :: builder_with_provider ( provider. into ( ) )
94
+ . with_safe_default_protocol_versions ( )
95
+ . map_err ( |e| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , e) ) ?
96
+ . with_platform_verifier ( )
97
+ . with_no_client_auth ( ) ,
98
+ ) )
99
+ }
100
+
79
101
/// Shorthand for using rustls' default crypto provider and safe defaults, with
80
102
/// native roots.
81
103
///
0 commit comments