@@ -74,7 +74,7 @@ use std::fmt;
7474use std:: fs;
7575use std:: path:: PathBuf ;
7676use std:: sync:: atomic:: AtomicBool ;
77- use std:: sync:: { Arc , Mutex , RwLock } ;
77+ use std:: sync:: { Arc , Mutex , Once , RwLock } ;
7878use std:: time:: SystemTime ;
7979use vss_client:: headers:: { FixedHeaders , LnurlAuthToJwtProvider , VssHeaderProvider } ;
8080
@@ -936,6 +936,8 @@ fn build_with_store_internal(
936936 liquidity_source_config : Option < & LiquiditySourceConfig > , seed_bytes : [ u8 ; 64 ] ,
937937 logger : Arc < Logger > , kv_store : Arc < DynStore > ,
938938) -> Result < Node , BuildError > {
939+ optionally_install_rustls_cryptoprovider ( ) ;
940+
939941 if let Err ( err) = may_announce_channel ( & config) {
940942 if config. announcement_addresses . is_some ( ) {
941943 log_error ! ( logger, "Announcement addresses were set but some required configuration options for node announcement are missing: {}" , err) ;
@@ -1525,6 +1527,25 @@ fn build_with_store_internal(
15251527 } )
15261528}
15271529
1530+ fn optionally_install_rustls_cryptoprovider ( ) {
1531+ // Acquire a global Mutex, ensuring that only one process at a time install the provider. This
1532+ // is mostly required for running tests concurrently.
1533+ static INIT_CRYPTO : Once = Once :: new ( ) ;
1534+
1535+ INIT_CRYPTO . call_once ( || {
1536+ // Ensure we always install a `CryptoProvider` for `rustls` if it was somehow not previously installed by now.
1537+ if rustls:: crypto:: CryptoProvider :: get_default ( ) . is_none ( ) {
1538+ let _ = rustls:: crypto:: aws_lc_rs:: default_provider ( ) . install_default ( ) ;
1539+ }
1540+
1541+ // Refuse to startup without TLS support. Better to catch it now than even later at runtime.
1542+ assert ! (
1543+ rustls:: crypto:: CryptoProvider :: get_default( ) . is_some( ) ,
1544+ "We need to have a CryptoProvider"
1545+ ) ;
1546+ } ) ;
1547+ }
1548+
15281549/// Sets up the node logger.
15291550fn setup_logger (
15301551 log_writer_config : & Option < LogWriterConfig > , config : & Config ,
0 commit comments