use rustls::crypto::CryptoProvider;
pub(crate) fn get_key_provider() -> &'static dyn rustls::crypto::KeyProvider {
let key_provider = CryptoProvider::get_default().map(|p| p.key_provider);
#[cfg(feature = "default-rustls-provider")]
let key_provider =
key_provider.unwrap_or_else(|| rustls::crypto::aws_lc_rs::default_provider().key_provider);
#[cfg(not(feature = "default-rustls-provider"))]
let key_provider = key_provider.expect(
r###"
The default rustls::CryptoProvider should be configured by the application. The
`google-cloud-auth` crate was compiled without the `default-rustls-provider`
feature. Without this feature the crate expects the application to initialize
the rustls crypto provider using `rustls::CryptoProvider::install_default()`.
Note that the application must use the exact same version of `rustls` as the
`google-cloud-auth` crate does. Otherwise `install_default()` has no effect."###,
);
key_provider
}