@@ -52,74 +52,64 @@ impl ConnectorBuilder<WantsTlsConfig> {
5252 ConnectorBuilder ( WantsSchemes { tls_config : config } )
5353 }
5454
55- /// Shorthand for using rustls' [ safe defaults][with_safe_defaults]
56- /// and native roots
55+ /// Shorthand for using rustls' default crypto provider and safe defaults, with
56+ /// native roots.
5757 ///
5858 /// See [`ConfigBuilderExt::with_native_roots`]
59- ///
60- /// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
6159 #[ cfg( all( feature = "ring" , feature = "rustls-native-certs" ) ) ]
6260 pub fn with_native_roots ( self ) -> std:: io:: Result < ConnectorBuilder < WantsSchemes > > {
6361 Ok ( self . with_tls_config (
6462 ClientConfig :: builder ( )
65- . with_safe_defaults ( )
6663 . with_native_roots ( ) ?
6764 . with_no_client_auth ( ) ,
6865 ) )
6966 }
7067
71- /// Shorthand for using rustls' [safe defaults][with_safe_defaults]
72- /// with a custom [`CryptoProvider`] and native roots
68+ /// Shorthand for using a custom [`CryptoProvider`] and native roots
7369 ///
7470 /// See [`ConfigBuilderExt::with_native_roots`]
75- ///
76- /// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
7771 #[ cfg( feature = "rustls-native-certs" ) ]
7872 pub fn with_provider_and_native_roots (
7973 self ,
80- provider : & ' static dyn CryptoProvider ,
74+ provider : CryptoProvider ,
8175 ) -> std:: io:: Result < ConnectorBuilder < WantsSchemes > > {
8276 Ok ( self . with_tls_config (
83- ClientConfig :: builder_with_provider ( provider)
84- . with_safe_defaults ( )
77+ ClientConfig :: builder_with_provider ( provider. into ( ) )
78+ . with_safe_default_protocol_versions ( )
79+ . map_err ( |e| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , e) ) ?
8580 . with_native_roots ( ) ?
8681 . with_no_client_auth ( ) ,
8782 ) )
8883 }
8984
90- /// Shorthand for using rustls' [safe defaults][with_safe_defaults]
91- /// and Mozilla roots
85+ /// Shorthand for using rustls' default crypto provider and its
86+ /// safe defaults.
9287 ///
9388 /// See [`ConfigBuilderExt::with_webpki_roots`]
94- ///
95- /// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
9689 #[ cfg( all( feature = "ring" , feature = "webpki-roots" ) ) ]
9790 pub fn with_webpki_roots ( self ) -> ConnectorBuilder < WantsSchemes > {
9891 self . with_tls_config (
9992 ClientConfig :: builder ( )
100- . with_safe_defaults ( )
10193 . with_webpki_roots ( )
10294 . with_no_client_auth ( ) ,
10395 )
10496 }
10597
106- /// Shorthand for using rustls' [safe defaults][with_safe_defaults]
107- /// with a custom [`CryptoProvider`] and Mozilla roots
98+ /// Shorthand for using a custom [`CryptoProvider`], Rustls' safe default
99+ /// protocol versions and Mozilla roots
108100 ///
109101 /// See [`ConfigBuilderExt::with_webpki_roots`]
110- ///
111- /// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
112102 #[ cfg( feature = "webpki-roots" ) ]
113103 pub fn with_provider_and_webpki_roots (
114104 self ,
115- provider : & ' static dyn CryptoProvider ,
116- ) -> ConnectorBuilder < WantsSchemes > {
117- self . with_tls_config (
118- ClientConfig :: builder_with_provider ( provider)
119- . with_safe_defaults ( )
105+ provider : CryptoProvider ,
106+ ) -> Result < ConnectorBuilder < WantsSchemes > , rustls :: Error > {
107+ Ok ( self . with_tls_config (
108+ ClientConfig :: builder_with_provider ( provider. into ( ) )
109+ . with_safe_default_protocol_versions ( ) ?
120110 . with_webpki_roots ( )
121111 . with_no_client_auth ( ) ,
122- )
112+ ) )
123113 }
124114}
125115
@@ -331,7 +321,6 @@ mod tests {
331321 fn test_reject_predefined_alpn ( ) {
332322 let roots = rustls:: RootCertStore :: empty ( ) ;
333323 let mut config_with_alpn = rustls:: ClientConfig :: builder ( )
334- . with_safe_defaults ( )
335324 . with_root_certificates ( roots)
336325 . with_no_client_auth ( ) ;
337326 config_with_alpn. alpn_protocols = vec ! [ b"fancyprotocol" . to_vec( ) ] ;
@@ -347,7 +336,6 @@ mod tests {
347336 fn test_alpn ( ) {
348337 let roots = rustls:: RootCertStore :: empty ( ) ;
349338 let tls_config = rustls:: ClientConfig :: builder ( )
350- . with_safe_defaults ( )
351339 . with_root_certificates ( roots)
352340 . with_no_client_auth ( ) ;
353341 let connector = super :: ConnectorBuilder :: new ( )
0 commit comments