Merge bitcoindevkit/rust-electrum-client#171: Install rustls's CryptoProvider based on features
f24458248aInstall `rustls`'s `CryptoProvider` based on features (Elias Rohrer) Pull request description: Previously, we'd already assume `use-rustls` to use the default `aws-lc-rs` provider and `use-rustls-ring` to use the `ring` `CryptoProvider`, e.g., for `NoCertificateVerification`. However, we **wouldn't** actually install the respective provider based on the features, leading to a **reachable** panic at runtime when user tried to access `ssl://` Electrum servers. Here, we fix this omission and install the default provider according to the configured features. (cc @oleonardolima @thunderbiscuit) ACKs for top commit: ValuedMammal: ACKf24458248aoleonardolima: ACKf24458248aTree-SHA512: b502b97e4162c0dd46e17ccf1c0a0a8461158dbec06833d7d8715072fa4feeb87beb3ee2dd93c594689ef0c2ecd84ed52a4f9309d826bebb95f3c9e57dd933fb
This commit is contained in:
commit
1372898ff2
@ -406,6 +406,29 @@ impl RawClient<ElectrumSslStream> {
|
||||
) -> Result<Self, Error> {
|
||||
use std::convert::TryFrom;
|
||||
|
||||
if rustls::crypto::CryptoProvider::get_default().is_none() {
|
||||
// We install a crypto provider depending on the set feature.
|
||||
#[cfg(feature = "use-rustls")]
|
||||
rustls::crypto::CryptoProvider::install_default(
|
||||
rustls::crypto::aws_lc_rs::default_provider(),
|
||||
)
|
||||
.map_err(|_| {
|
||||
Error::CouldNotCreateConnection(rustls::Error::General(
|
||||
"Failed to install CryptoProvider".to_string(),
|
||||
))
|
||||
})?;
|
||||
|
||||
#[cfg(feature = "use-rustls-ring")]
|
||||
rustls::crypto::CryptoProvider::install_default(
|
||||
rustls::crypto::ring::default_provider(),
|
||||
)
|
||||
.map_err(|_| {
|
||||
Error::CouldNotCreateConnection(rustls::Error::General(
|
||||
"Failed to install CryptoProvider".to_string(),
|
||||
))
|
||||
})?;
|
||||
}
|
||||
|
||||
let builder = ClientConfig::builder();
|
||||
|
||||
let config = if validate_domain {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user