1use std::sync::OnceLock;
4
5static RUSTLS_PROVIDER_INSTALLED: OnceLock<()> = OnceLock::new();
6
7pub fn ensure_rustls_crypto_provider() {
13 RUSTLS_PROVIDER_INSTALLED.get_or_init(|| {
14 if rustls::crypto::CryptoProvider::get_default().is_none() {
15 if rustls::crypto::ring::default_provider()
16 .install_default()
17 .is_err()
18 {
19 panic!(
20 "Failed to install rustls crypto provider. \
21 cuenv requires a working rustls provider when built with `rustls-no-provider`."
22 );
23 }
24 if rustls::crypto::CryptoProvider::get_default().is_none() {
25 panic!(
26 "rustls crypto provider is still missing after installation attempt. \
27 Another incompatible provider may have been installed earlier in the process."
28 );
29 }
30 }
31 });
32}