From da6b0a204036371d991c93aee39de2b1d454dc3d Mon Sep 17 00:00:00 2001 From: fluidvanadium Date: Wed, 18 Sep 2024 20:11:15 +0000 Subject: [PATCH] moved rustls::crypto::ring init into GrpcConnector.get_client --- Cargo.lock | 2 +- Cargo.toml | 1 + zingo-netutils/Cargo.toml | 1 + zingo-netutils/src/lib.rs | 5 +++++ zingocli/Cargo.toml | 1 - zingocli/src/lib.rs | 6 ------ 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb22bd232..265225d02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4262,7 +4262,6 @@ dependencies = [ "http", "json", "log", - "rustls", "rustyline", "shellwords", "zingolib", @@ -4290,6 +4289,7 @@ dependencies = [ "hyper-rustls", "hyper-util", "prost", + "rustls", "rustls-pemfile 1.0.4", "thiserror", "tokio-rustls", diff --git a/Cargo.toml b/Cargo.toml index c9908b028..c9f54b6f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -74,6 +74,7 @@ rand = "0.8.5" reqwest = "0.12" ring = "0.17.0" rust-embed = "6.3.0" +rustls = { version = "0.23.13", features = ["ring"] } rustls-pemfile = "1.0.0" rustyline = "11.0.0" secp256k1 = "=0.27.0" diff --git a/zingo-netutils/Cargo.toml b/zingo-netutils/Cargo.toml index 23e50a221..556299a12 100644 --- a/zingo-netutils/Cargo.toml +++ b/zingo-netutils/Cargo.toml @@ -12,6 +12,7 @@ hyper-rustls.workspace = true hyper-util.workspace = true hyper.workspace = true prost.workspace = true +rustls.workspace = true rustls-pemfile = { workspace = true } thiserror.workspace = true tokio-rustls.workspace = true diff --git a/zingo-netutils/src/lib.rs b/zingo-netutils/src/lib.rs index 09b0b3ecb..c93364e42 100644 --- a/zingo-netutils/src/lib.rs +++ b/zingo-netutils/src/lib.rs @@ -85,6 +85,11 @@ impl GrpcConnector { > { let uri = Arc::new(self.uri.clone()); async move { + // install default crypto provider (ring) + if let Err(e) = rustls::crypto::ring::default_provider().install_default() { + eprintln!("Error installing crypto provider: {:?}", e) + }; + let mut http_connector = HttpConnector::new(); http_connector.enforce_http(false); let scheme = uri.scheme().ok_or(GetClientError::InvalidScheme)?.clone(); diff --git a/zingocli/Cargo.toml b/zingocli/Cargo.toml index 0f4448d43..c3beb5f2a 100644 --- a/zingocli/Cargo.toml +++ b/zingocli/Cargo.toml @@ -5,7 +5,6 @@ edition = "2021" [dependencies] zingolib = { path = "../zingolib/", features = ["deprecations", "test-elevation"] } -rustls = { version = "0.23.13", features = ["ring"] } clap = { workspace = true } http = { workspace = true } diff --git a/zingocli/src/lib.rs b/zingocli/src/lib.rs index e2d0756b7..23c0f9a2e 100644 --- a/zingocli/src/lib.rs +++ b/zingocli/src/lib.rs @@ -11,7 +11,6 @@ use std::sync::Arc; use log::{error, info}; use clap::{self, Arg}; -use rustls; use zingolib::config::ChainType; use zingolib::testutils::regtest; use zingolib::wallet::WalletBase; @@ -514,11 +513,6 @@ fn dispatch_command_or_start_interactive(cli_config: &ConfigTemplate) { /// TODO: Add Doc Comment Here! pub fn run_cli() { - // install default crypto provider (ring) - if let Err(e) = rustls::crypto::ring::default_provider().install_default() { - eprintln!("Error installing crypto provider: {:?}", e) - }; - // Initialize logging if let Err(e) = LightClient::init_logging() { eprintln!("Could not initialize logging: {e}")