@@ -75,7 +75,7 @@ use std::fmt;
75
75
use std:: fs;
76
76
use std:: path:: PathBuf ;
77
77
use std:: sync:: atomic:: AtomicBool ;
78
- use std:: sync:: { Arc , Mutex , RwLock } ;
78
+ use std:: sync:: { Arc , Mutex , Once , RwLock } ;
79
79
use std:: time:: SystemTime ;
80
80
use vss_client:: headers:: { FixedHeaders , LnurlAuthToJwtProvider , VssHeaderProvider } ;
81
81
@@ -1051,6 +1051,8 @@ fn build_with_store_internal(
1051
1051
liquidity_source_config : Option < & LiquiditySourceConfig > , seed_bytes : [ u8 ; 64 ] ,
1052
1052
logger : Arc < Logger > , kv_store : Arc < DynStore > ,
1053
1053
) -> Result < Node , BuildError > {
1054
+ optionally_install_rustls_cryptoprovider ( ) ;
1055
+
1054
1056
if let Err ( err) = may_announce_channel ( & config) {
1055
1057
if config. announcement_addresses . is_some ( ) {
1056
1058
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(
1663
1665
} )
1664
1666
}
1665
1667
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
+
1666
1687
/// Sets up the node logger.
1667
1688
fn setup_logger (
1668
1689
log_writer_config : & Option < LogWriterConfig > , config : & Config ,
0 commit comments