Skip to content

Commit 6968cbe

Browse files
committed
Install rustls's CryptoProvider based on features
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.
1 parent 7de4cb7 commit 6968cbe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/raw_client.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ impl RawClient<ElectrumSslStream> {
406406
) -> Result<Self, Error> {
407407
use std::convert::TryFrom;
408408

409+
// We install a crypto provider depending on the set feature.
410+
#[cfg(feature = "use-rustls")]
411+
rustls::crypto::CryptoProvider::install_default(rustls::crypto::aws_lc_rs::default_provider()).unwrap();
412+
413+
#[cfg(feature = "use-rustls-ring")]
414+
rustls::crypto::CryptoProvider::install_default(rustls::crypto::ring::default_provider()).unwrap();
415+
409416
let builder = ClientConfig::builder();
410417

411418
let config = if validate_domain {

0 commit comments

Comments
 (0)