From 3c9f6f37491915bad714e3d5216f18c7e24163e2 Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Mon, 5 Feb 2024 09:23:19 -0500 Subject: [PATCH 1/2] Make cert-manager a sub-crate --- Cargo.toml | 1 + core/cert-manager/Cargo.toml | 29 +++++++++++++++++++ core/cert-manager/src/lib.rs | 1 + .../cert_manager => cert-manager/src}/x509.rs | 0 core/network/Cargo.toml | 1 + core/network/examples/peer_outbound_ping.rs | 2 +- core/network/src/cert_manager/mod.rs | 2 -- core/network/src/lib.rs | 1 - core/network/src/peer/inbound.rs | 1 - core/network/src/peer/mod.rs | 4 +-- core/network/src/peer/outbound.rs | 1 - crates/avalanche-types/Cargo.toml | 2 +- tests/avalanchego-byzantine/Cargo.toml | 2 +- tests/avalanchego-conformance/Cargo.toml | 2 +- 14 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 core/cert-manager/Cargo.toml create mode 100644 core/cert-manager/src/lib.rs rename core/{network/src/cert_manager => cert-manager/src}/x509.rs (100%) delete mode 100644 core/network/src/cert_manager/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 1038420..03fbe61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "avalanchego-conformance-sdk", + "core/cert-manager", "core/network", "core/server", "crates/avalanche-consensus", diff --git a/core/cert-manager/Cargo.toml b/core/cert-manager/Cargo.toml new file mode 100644 index 0000000..755a610 --- /dev/null +++ b/core/cert-manager/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "cert-manager" +version = "0.0.11" # https://crates.io/crates/cert-manager + +edition = "2021" +rust-version = "1.69" +publish = true +description = "Cert manager in Rust" +# copied-from: +repository = "https://github.com/gyuho/cert-manager" +readme = "README.md" +license = "Apache-2.0" + +[dependencies] +log = "0.4.20" +rand = "0.8.5" +random-manager = "0.0.5" # https://crates.io/crates/random-manager/versions +rcgen = { version = "0.11.3", features = ["pem", "x509-parser"] } +rsa = { version = "0.9.2", features = ["pem"] } # https://crates.io/crates/rsa +rustls = "0.21.8" +rustls-pemfile = "1.0.3" +x509-parser = "0.15.1" + +[dev-dependencies] +env_logger = "0.10.0" +tempfile = "3.5.0" + +[package.metadata.cargo-udeps.ignore] +normal = ["rsa"] diff --git a/core/cert-manager/src/lib.rs b/core/cert-manager/src/lib.rs new file mode 100644 index 0000000..952fc9c --- /dev/null +++ b/core/cert-manager/src/lib.rs @@ -0,0 +1 @@ +pub mod x509; diff --git a/core/network/src/cert_manager/x509.rs b/core/cert-manager/src/x509.rs similarity index 100% rename from core/network/src/cert_manager/x509.rs rename to core/cert-manager/src/x509.rs diff --git a/core/network/Cargo.toml b/core/network/Cargo.toml index 77788cc..17aa312 100644 --- a/core/network/Cargo.toml +++ b/core/network/Cargo.toml @@ -26,6 +26,7 @@ rustls-pemfile = "1.0.3" x509-parser = "0.15.1" # for feature "pem" pem = { version = "3.0.0", optional = true } # https://github.com/jcreekmore/pem-rs +cert-manager = { path = "../../core/cert-manager" } [dev-dependencies] env_logger = "0.11.1" diff --git a/core/network/examples/peer_outbound_ping.rs b/core/network/examples/peer_outbound_ping.rs index d85537a..0d167fc 100644 --- a/core/network/examples/peer_outbound_ping.rs +++ b/core/network/examples/peer_outbound_ping.rs @@ -8,7 +8,7 @@ use std::{ }; use avalanche_types::{ids::Id, message}; -use network::{cert_manager, peer::outbound}; +use network::peer::outbound; /// cargo run --example peer_outbound_ping -- [PEER IP] [STAKING PORT] /// cargo run --example peer_outbound_ping -- 34.222.2.60 9651 diff --git a/core/network/src/cert_manager/mod.rs b/core/network/src/cert_manager/mod.rs deleted file mode 100644 index e907203..0000000 --- a/core/network/src/cert_manager/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -/// This module is a copy of the cert-manager crate by gyuho (https://github.com/gyuho/cert-manager) -pub mod x509; diff --git a/core/network/src/lib.rs b/core/network/src/lib.rs index 56fa8e6..2e7ce1a 100644 --- a/core/network/src/lib.rs +++ b/core/network/src/lib.rs @@ -1,3 +1,2 @@ //! A library for building p2p inbound and outbound connections. -pub mod cert_manager; pub mod peer; diff --git a/core/network/src/peer/inbound.rs b/core/network/src/peer/inbound.rs index a0a1d30..23cb1c7 100644 --- a/core/network/src/peer/inbound.rs +++ b/core/network/src/peer/inbound.rs @@ -4,7 +4,6 @@ use std::{ sync::Arc, }; -use crate::cert_manager; use hyper::server::conn::AddrIncoming; use rustls::server::NoClientAuth; use tokio_rustls::rustls::ServerConfig; diff --git a/core/network/src/peer/mod.rs b/core/network/src/peer/mod.rs index 1fdf7c6..91f303a 100644 --- a/core/network/src/peer/mod.rs +++ b/core/network/src/peer/mod.rs @@ -25,6 +25,7 @@ impl Peer { /// Error is Os { code: 61, kind: ConnectionRefused, message: "Connection refused" } when connecting client to server. #[cfg(test)] mod test { + use crate::peer::outbound; use rcgen::CertificateParams; use rustls::ServerConfig; use std::{ @@ -36,9 +37,6 @@ mod test { use tokio::net::TcpListener; use tokio_rustls::TlsAcceptor; - use crate::cert_manager; - use crate::peer::outbound; - #[tokio::test] #[ignore] async fn test_listener() -> io::Result<()> { diff --git a/core/network/src/peer/outbound.rs b/core/network/src/peer/outbound.rs index cf416a8..bef4d62 100644 --- a/core/network/src/peer/outbound.rs +++ b/core/network/src/peer/outbound.rs @@ -8,7 +8,6 @@ use std::{ use avalanche_types::ids::node; -use crate::cert_manager; use log::info; use pem::Pem; use rustls::Certificate; diff --git a/crates/avalanche-types/Cargo.toml b/crates/avalanche-types/Cargo.toml index 8e2cd74..a7aa348 100644 --- a/crates/avalanche-types/Cargo.toml +++ b/crates/avalanche-types/Cargo.toml @@ -19,7 +19,7 @@ bech32 = "0.9.1" blst = "0.3.10" # https://github.com/supranational/blst/tree/master/bindings/rust, for "BLS bs58 = { version = "0.5.0", features = ["cb58"] } bytes = "1.4.0" -cert-manager = "0.0.11" # https://github.com/gyuho/cert-manager +cert-manager = { path = "../../core/cert-manager" } chrono = "0.4.26" cmp-manager = "0.0.1" ecdsa = { version = "0.16.7", features = ["rfc6979", "verifying"] } # https://github.com/RustCrypto/elliptic-curves/tree/master/k256 diff --git a/tests/avalanchego-byzantine/Cargo.toml b/tests/avalanchego-byzantine/Cargo.toml index b5833d8..07a4c93 100644 --- a/tests/avalanchego-byzantine/Cargo.toml +++ b/tests/avalanchego-byzantine/Cargo.toml @@ -14,7 +14,7 @@ homepage = "https://avax.network" avalanche-installer = "0.0.77" avalanche-network-runner-sdk = "0.3.3" # https://crates.io/crates/avalanche-network-runner-sdk avalanche-types = { path = "../../crates/avalanche-types", features = ["jsonrpc_client"] } # https://crates.io/crates/avalanche-types -cert-manager = "0.0.11" # https://github.com/gyuho/cert-manager +cert-manager = { path = "../../core/cert-manager" } env_logger = "0.11.1" hex = "0.4.3" log = "0.4.20" diff --git a/tests/avalanchego-conformance/Cargo.toml b/tests/avalanchego-conformance/Cargo.toml index dd0ed69..fc80ec7 100644 --- a/tests/avalanchego-conformance/Cargo.toml +++ b/tests/avalanchego-conformance/Cargo.toml @@ -13,7 +13,7 @@ homepage = "https://avax.network" [dev-dependencies] avalanche-types = { path = "../../crates/avalanche-types", features = ["libsecp256k1", "message"] } avalanchego-conformance-sdk = { path = "../../avalanchego-conformance-sdk" } -cert-manager = "0.0.11" # https://github.com/gyuho/cert-manager +cert-manager = { path = "../../core/cert-manager" } env_logger = "0.11.1" log = "0.4.20" random-manager = "0.0.5" From c90bfc579f44f22e901831c858dba3784433991a Mon Sep 17 00:00:00 2001 From: Richard Pringle Date: Thu, 8 Feb 2024 09:55:21 -0500 Subject: [PATCH 2/2] Update rcgen --- core/cert-manager/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cert-manager/Cargo.toml b/core/cert-manager/Cargo.toml index 755a610..d8870ec 100644 --- a/core/cert-manager/Cargo.toml +++ b/core/cert-manager/Cargo.toml @@ -15,7 +15,7 @@ license = "Apache-2.0" log = "0.4.20" rand = "0.8.5" random-manager = "0.0.5" # https://crates.io/crates/random-manager/versions -rcgen = { version = "0.11.3", features = ["pem", "x509-parser"] } +rcgen = { version = "0.12.1", features = ["pem", "x509-parser"] } rsa = { version = "0.9.2", features = ["pem"] } # https://crates.io/crates/rsa rustls = "0.21.8" rustls-pemfile = "1.0.3"