Skip to main content

huddle_core/
lib.rs

1pub mod app;
2pub mod config;
3pub mod crypto;
4pub mod error;
5pub mod files;
6pub mod identity;
7pub mod invite;
8pub mod network;
9pub mod storage;
10
11/// Install the process-wide rustls [`CryptoProvider`] (ring), idempotently.
12///
13/// rustls 0.23 builds no TLS config until a provider is selected. It *can*
14/// auto-pick one from crate features, but only when exactly one of rustls'
15/// `ring`/`aws-lc-rs` features is enabled in the final binary's dependency
16/// closure. huddle-core pulls rustls via tokio-tungstenite's `wss://` door
17/// without a provider feature, so before this fix only the TUI worked (it
18/// enables `ring` transitively through `ureq`); huddle-gui's `wss` worker
19/// thread panicked at startup. We now depend on rustls' `ring` directly and
20/// install it here, so every consumer is deterministic regardless of which
21/// other crates happen to be in the closure.
22///
23/// Called at the top of the [`AppHandle`](crate::app::AppHandle) start path,
24/// before any transport door builds a TLS config. Safe to call repeatedly —
25/// a second call (or one racing a transitive dep's install) is a no-op.
26///
27/// [`CryptoProvider`]: https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html
28pub fn install_default_crypto_provider() {
29    // `install_default` returns Err if a provider was already installed — by
30    // an earlier call here or by a transitive dependency. Either way the
31    // process has a provider afterward, so the error is not actionable.
32    let _ = rustls::crypto::ring::default_provider().install_default();
33}