@@ -17,12 +17,15 @@ use crate::config::ConfigBuilderExt;
1717/// ```
1818/// use hyper_rustls::HttpsConnectorBuilder;
1919///
20- /// # #[cfg(all(feature = "webpki-roots", feature = "http1"))]
21- /// let https = HttpsConnectorBuilder::new()
20+ /// # #[cfg(all(feature = "webpki-roots", feature = "http1", feature="aws-lc-rs"))]
21+ /// # {
22+ /// # let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
23+ /// let https = HttpsConnectorBuilder::new()
2224/// .with_webpki_roots()
2325/// .https_only()
2426/// .enable_http1()
2527/// .build();
28+ /// # }
2629/// ```
2730pub struct ConnectorBuilder < State > ( State ) ;
2831
@@ -54,7 +57,10 @@ impl ConnectorBuilder<WantsTlsConfig> {
5457 /// Use rustls' default crypto provider and other defaults, and the platform verifier
5558 ///
5659 /// See [`ConfigBuilderExt::with_platform_verifier()`].
57- #[ cfg( all( feature = "ring" , feature = "rustls-platform-verifier" ) ) ]
60+ #[ cfg( all(
61+ any( feature = "ring" , feature = "aws-lc-rs" ) ,
62+ feature = "rustls-platform-verifier"
63+ ) ) ]
5864 pub fn with_platform_verifier ( self ) -> ConnectorBuilder < WantsSchemes > {
5965 self . with_tls_config (
6066 ClientConfig :: builder ( )
@@ -67,7 +73,10 @@ impl ConnectorBuilder<WantsTlsConfig> {
6773 /// native roots.
6874 ///
6975 /// See [`ConfigBuilderExt::with_native_roots`]
70- #[ cfg( all( feature = "ring" , feature = "rustls-native-certs" ) ) ]
76+ #[ cfg( all(
77+ any( feature = "ring" , feature = "aws-lc-rs" ) ,
78+ feature = "rustls-native-certs"
79+ ) ) ]
7180 pub fn with_native_roots ( self ) -> std:: io:: Result < ConnectorBuilder < WantsSchemes > > {
7281 Ok ( self . with_tls_config (
7382 ClientConfig :: builder ( )
@@ -97,7 +106,7 @@ impl ConnectorBuilder<WantsTlsConfig> {
97106 /// safe defaults.
98107 ///
99108 /// See [`ConfigBuilderExt::with_webpki_roots`]
100- #[ cfg( all( feature = "ring" , feature = "webpki-roots" ) ) ]
109+ #[ cfg( all( any ( feature = "ring" , feature = "aws-lc-rs" ) , feature = "webpki-roots" ) ) ]
101110 pub fn with_webpki_roots ( self ) -> ConnectorBuilder < WantsSchemes > {
102111 self . with_tls_config (
103112 ClientConfig :: builder ( )
@@ -316,6 +325,7 @@ mod tests {
316325 #[ test]
317326 #[ cfg( all( feature = "webpki-roots" , feature = "http1" ) ) ]
318327 fn test_builder ( ) {
328+ ensure_global_state ( ) ;
319329 let _connector = super :: ConnectorBuilder :: new ( )
320330 . with_webpki_roots ( )
321331 . https_only ( )
@@ -327,6 +337,7 @@ mod tests {
327337 #[ cfg( feature = "http1" ) ]
328338 #[ should_panic( expected = "ALPN protocols should not be pre-defined" ) ]
329339 fn test_reject_predefined_alpn ( ) {
340+ ensure_global_state ( ) ;
330341 let roots = rustls:: RootCertStore :: empty ( ) ;
331342 let mut config_with_alpn = rustls:: ClientConfig :: builder ( )
332343 . with_root_certificates ( roots)
@@ -342,6 +353,7 @@ mod tests {
342353 #[ test]
343354 #[ cfg( all( feature = "http1" , feature = "http2" ) ) ]
344355 fn test_alpn ( ) {
356+ ensure_global_state ( ) ;
345357 let roots = rustls:: RootCertStore :: empty ( ) ;
346358 let tls_config = rustls:: ClientConfig :: builder ( )
347359 . with_root_certificates ( roots)
@@ -403,4 +415,11 @@ mod tests {
403415 . build ( ) ;
404416 assert_eq ! ( & connector. tls_config. alpn_protocols, & [ b"h2" . to_vec( ) ] ) ;
405417 }
418+
419+ fn ensure_global_state ( ) {
420+ #[ cfg( feature = "ring" ) ]
421+ let _ = rustls:: crypto:: ring:: default_provider ( ) . install_default ( ) ;
422+ #[ cfg( feature = "aws-lc-rs" ) ]
423+ let _ = rustls:: crypto:: aws_lc_rs:: default_provider ( ) . install_default ( ) ;
424+ }
406425}
0 commit comments