Skip to content

Commit a864aa8

Browse files
Fix installing crypto provider when it's already installed
1 parent 4637657 commit a864aa8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mycelium/src/peer_manager.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,9 +1231,12 @@ fn make_quic_endpoint(
12311231
quic_listen_port: u16,
12321232
firewall_mark: Option<u32>,
12331233
) -> Result<quinn::Endpoint, Box<dyn std::error::Error>> {
1234-
// Install ring crypto provider for rustls
1235-
rustls::crypto::CryptoProvider::install_default(rustls::crypto::ring::default_provider())
1236-
.expect("Crypto provider has not been installed yet");
1234+
// Install ring crypto provider for rustls (only if not already installed)
1235+
if rustls::crypto::CryptoProvider::get_default().is_none() {
1236+
rustls::crypto::CryptoProvider::install_default(rustls::crypto::ring::default_provider())
1237+
.expect("Failed to install crypto provider");
1238+
}
1239+
12371240
// Generate self signed certificate certificate.
12381241
// TODO: sign with router keys
12391242
let cert = rcgen::generate_simple_self_signed(vec![format!("{router_id}")])?;

0 commit comments

Comments
 (0)