@@ -75,7 +75,7 @@ use std::fmt;
7575use std:: fs;
7676use std:: path:: PathBuf ;
7777use std:: sync:: atomic:: AtomicBool ;
78- use std:: sync:: { Arc , Mutex , RwLock } ;
78+ use std:: sync:: { Arc , Mutex , Once , RwLock } ;
7979use std:: time:: SystemTime ;
8080use vss_client:: headers:: { FixedHeaders , LnurlAuthToJwtProvider , VssHeaderProvider } ;
8181
@@ -1051,6 +1051,8 @@ fn build_with_store_internal(
10511051 liquidity_source_config : Option < & LiquiditySourceConfig > , seed_bytes : [ u8 ; 64 ] ,
10521052 logger : Arc < Logger > , kv_store : Arc < DynStore > ,
10531053) -> Result < Node , BuildError > {
1054+ optionally_install_rustls_cryptoprovider ( ) ;
1055+
10541056 if let Err ( err) = may_announce_channel ( & config) {
10551057 if config. announcement_addresses . is_some ( ) {
10561058 log_error ! ( logger, "Announcement addresses were set but some required configuration options for node announcement are missing: {}" , err) ;
@@ -1663,6 +1665,25 @@ fn build_with_store_internal(
16631665 } )
16641666}
16651667
1668+ fn optionally_install_rustls_cryptoprovider ( ) {
1669+ // Acquire a global Mutex, ensuring that only one process at a time install the provider. This
1670+ // is mostly required for running tests concurrently.
1671+ static INIT_CRYPTO : Once = Once :: new ( ) ;
1672+
1673+ INIT_CRYPTO . call_once ( || {
1674+ // Ensure we always install a `CryptoProvider` for `rustls` if it was somehow not previously installed by now.
1675+ if rustls:: crypto:: CryptoProvider :: get_default ( ) . is_none ( ) {
1676+ let _ = rustls:: crypto:: aws_lc_rs:: default_provider ( ) . install_default ( ) ;
1677+ }
1678+
1679+ // Refuse to startup without TLS support. Better to catch it now than even later at runtime.
1680+ assert ! (
1681+ rustls:: crypto:: CryptoProvider :: get_default( ) . is_some( ) ,
1682+ "We need to have a CryptoProvider"
1683+ ) ;
1684+ } ) ;
1685+ }
1686+
16661687/// Sets up the node logger.
16671688fn setup_logger (
16681689 log_writer_config : & Option < LogWriterConfig > , config : & Config ,
0 commit comments