spin_tls/lib.rs
1use std::sync::Once;
2
3static INSTALL_DEFAULT_CRYPTO_PROVIDER: Once = Once::new();
4
5/// Install Spin's process-wide rustls crypto provider.
6///
7/// This is idempotent for Spin's own duplicate calls from `main` and the trigger,
8/// but fails loudly if something else installed a rustls provider first.
9pub fn install_default_crypto_provider() {
10 INSTALL_DEFAULT_CRYPTO_PROVIDER.call_once(|| {
11 rustls::crypto::ring::default_provider()
12 .install_default()
13 .expect("failed to install rustls ring crypto provider");
14 });
15}