#[cfg(any(feature = "private-key-auth", feature = "browser-auth"))]
use std::sync::Arc;
#[cfg(any(
feature = "private-key-auth",
feature = "browser-auth",
feature = "aws-lc",
feature = "ring"
))]
use rustls::crypto::CryptoProvider;
#[cfg(feature = "aws-lc")]
use rustls::crypto::aws_lc_rs;
#[cfg(all(feature = "ring", not(feature = "aws-lc")))]
use rustls::crypto::ring;
pub fn install_default_crypto_provider() {
#[cfg(any(feature = "aws-lc", feature = "ring"))]
if CryptoProvider::get_default().is_none() {
#[cfg(feature = "aws-lc")]
drop(aws_lc_rs::default_provider().install_default());
#[cfg(all(feature = "ring", not(feature = "aws-lc")))]
drop(ring::default_provider().install_default());
}
}
#[cfg(any(feature = "private-key-auth", feature = "browser-auth"))]
use crate::{CredentialError, CredentialResult};
#[cfg(any(feature = "private-key-auth", feature = "browser-auth"))]
pub(crate) fn crypto_provider() -> CredentialResult<Arc<CryptoProvider>> {
install_default_crypto_provider();
CryptoProvider::get_default().cloned().ok_or_else(|| {
CredentialError::invalid(
"no rustls crypto provider: enable the `aws-lc` or `ring` feature, or install a \
process-default provider first",
)
})
}