@@ -74,7 +74,7 @@ use std::fmt;
74
74
use std:: fs;
75
75
use std:: path:: PathBuf ;
76
76
use std:: sync:: atomic:: AtomicBool ;
77
- use std:: sync:: { Arc , Mutex , RwLock } ;
77
+ use std:: sync:: { Arc , Mutex , Once , RwLock } ;
78
78
use std:: time:: SystemTime ;
79
79
use vss_client:: headers:: { FixedHeaders , LnurlAuthToJwtProvider , VssHeaderProvider } ;
80
80
@@ -936,6 +936,8 @@ fn build_with_store_internal(
936
936
liquidity_source_config : Option < & LiquiditySourceConfig > , seed_bytes : [ u8 ; 64 ] ,
937
937
logger : Arc < Logger > , kv_store : Arc < DynStore > ,
938
938
) -> Result < Node , BuildError > {
939
+ optionally_install_rustls_cryptoprovider ( ) ;
940
+
939
941
if let Err ( err) = may_announce_channel ( & config) {
940
942
if config. announcement_addresses . is_some ( ) {
941
943
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(
1525
1527
} )
1526
1528
}
1527
1529
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
+
1528
1549
/// Sets up the node logger.
1529
1550
fn setup_logger (
1530
1551
log_writer_config : & Option < LogWriterConfig > , config : & Config ,
0 commit comments