@@ -17,12 +17,15 @@ use crate::config::ConfigBuilderExt;
17
17
/// ```
18
18
/// use hyper_rustls::HttpsConnectorBuilder;
19
19
///
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()
22
24
/// .with_webpki_roots()
23
25
/// .https_only()
24
26
/// .enable_http1()
25
27
/// .build();
28
+ /// # }
26
29
/// ```
27
30
pub struct ConnectorBuilder < State > ( State ) ;
28
31
@@ -54,7 +57,10 @@ impl ConnectorBuilder<WantsTlsConfig> {
54
57
/// Use rustls' default crypto provider and other defaults, and the platform verifier
55
58
///
56
59
/// 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
+ ) ) ]
58
64
pub fn with_platform_verifier ( self ) -> ConnectorBuilder < WantsSchemes > {
59
65
self . with_tls_config (
60
66
ClientConfig :: builder ( )
@@ -67,7 +73,10 @@ impl ConnectorBuilder<WantsTlsConfig> {
67
73
/// native roots.
68
74
///
69
75
/// 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
+ ) ) ]
71
80
pub fn with_native_roots ( self ) -> std:: io:: Result < ConnectorBuilder < WantsSchemes > > {
72
81
Ok ( self . with_tls_config (
73
82
ClientConfig :: builder ( )
@@ -97,7 +106,7 @@ impl ConnectorBuilder<WantsTlsConfig> {
97
106
/// safe defaults.
98
107
///
99
108
/// 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" ) ) ]
101
110
pub fn with_webpki_roots ( self ) -> ConnectorBuilder < WantsSchemes > {
102
111
self . with_tls_config (
103
112
ClientConfig :: builder ( )
@@ -316,6 +325,7 @@ mod tests {
316
325
#[ test]
317
326
#[ cfg( all( feature = "webpki-roots" , feature = "http1" ) ) ]
318
327
fn test_builder ( ) {
328
+ ensure_global_state ( ) ;
319
329
let _connector = super :: ConnectorBuilder :: new ( )
320
330
. with_webpki_roots ( )
321
331
. https_only ( )
@@ -327,6 +337,7 @@ mod tests {
327
337
#[ cfg( feature = "http1" ) ]
328
338
#[ should_panic( expected = "ALPN protocols should not be pre-defined" ) ]
329
339
fn test_reject_predefined_alpn ( ) {
340
+ ensure_global_state ( ) ;
330
341
let roots = rustls:: RootCertStore :: empty ( ) ;
331
342
let mut config_with_alpn = rustls:: ClientConfig :: builder ( )
332
343
. with_root_certificates ( roots)
@@ -342,6 +353,7 @@ mod tests {
342
353
#[ test]
343
354
#[ cfg( all( feature = "http1" , feature = "http2" ) ) ]
344
355
fn test_alpn ( ) {
356
+ ensure_global_state ( ) ;
345
357
let roots = rustls:: RootCertStore :: empty ( ) ;
346
358
let tls_config = rustls:: ClientConfig :: builder ( )
347
359
. with_root_certificates ( roots)
@@ -403,4 +415,11 @@ mod tests {
403
415
. build ( ) ;
404
416
assert_eq ! ( & connector. tls_config. alpn_protocols, & [ b"h2" . to_vec( ) ] ) ;
405
417
}
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
+ }
406
425
}
0 commit comments