From f88c3812bcba90ece4564b690ee00e0d0abdb660 Mon Sep 17 00:00:00 2001 From: Jacobtread Date: Mon, 1 Jan 2024 20:08:00 +1300 Subject: [PATCH] Updated backing SSL impl --- Cargo.lock | 215 +++++++++++++++++++--------------- Cargo.toml | 2 +- src/services/retriever/mod.rs | 6 +- 3 files changed, 122 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49dfffc..84be445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -250,11 +250,13 @@ dependencies = [ [[package]] name = "blaze-ssl-async" -version = "0.3.7" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98ee6687c94bbb4f40bc46ac4d617ec01d7128ef7b195b5a8f0ba40a1ba75b77" +checksum = "6fec08f35919613bda0b3eb3bc772c2f793b3634133923b931874b18e1ac55de" dependencies = [ - "rsa 0.8.2", + "bytes", + "num_enum", + "rsa", "tokio", "x509-cert", ] @@ -435,19 +437,6 @@ dependencies = [ "syn 2.0.42", ] -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "der_derive", - "flagset", - "pem-rfc7468 0.6.0", - "zeroize", -] - [[package]] name = "der" version = "0.7.8" @@ -455,20 +444,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", - "pem-rfc7468 0.7.0", + "der_derive", + "flagset", + "pem-rfc7468", "zeroize", ] [[package]] name = "der_derive" -version = "0.6.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ef71ddb5b3a1f53dee24817c8f70dfa1cb29e804c18d88c228d4bc9c86ee3b9" +checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.42", ] [[package]] @@ -1298,6 +1288,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.42", +] + [[package]] name = "object" version = "0.32.1" @@ -1386,15 +1397,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -1442,37 +1444,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs1" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff33bdbdfc54cc98a2eca766ebdec3e1b8fb7387523d5c9c9a2891da856f719" -dependencies = [ - "der 0.6.1", - "pkcs8 0.9.0", - "spki 0.6.0", - "zeroize", -] - [[package]] name = "pkcs1" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ - "der 0.7.8", - "pkcs8 0.10.2", - "spki 0.7.3", -] - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der 0.6.1", - "spki 0.6.0", + "der", + "pkcs8", + "spki", ] [[package]] @@ -1481,8 +1461,8 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.8", - "spki 0.7.3", + "der", + "spki", ] [[package]] @@ -1535,6 +1515,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "proc-macro-crate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +dependencies = [ + "toml_datetime", + "toml_edit", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -1714,26 +1704,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rsa" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55a77d189da1fee555ad95b7e50e7457d91c0e089ec68ca69ad2989413bbdab4" -dependencies = [ - "byteorder", - "digest", - "num-bigint-dig", - "num-integer", - "num-iter", - "num-traits", - "pkcs1 0.4.1", - "pkcs8 0.9.0", - "rand_core", - "signature", - "subtle", - "zeroize", -] - [[package]] name = "rsa" version = "0.9.6" @@ -1745,11 +1715,11 @@ dependencies = [ "num-bigint-dig", "num-integer", "num-traits", - "pkcs1 0.7.5", - "pkcs8 0.10.2", + "pkcs1", + "pkcs8", "rand_core", "signature", - "spki 0.7.3", + "spki", "subtle", "zeroize", ] @@ -2108,16 +2078,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - [[package]] name = "spki" version = "0.7.3" @@ -2125,7 +2085,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.8", + "der", ] [[package]] @@ -2267,7 +2227,7 @@ dependencies = [ "once_cell", "percent-encoding", "rand", - "rsa 0.9.6", + "rsa", "serde", "sha1", "sha2", @@ -2517,6 +2477,27 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "tls_codec" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38a1d5fcfa859f0ec2b5e111dc903890bd7dac7f34713232bf9aa4fd7cad7b2" +dependencies = [ + "tls_codec_derive", + "zeroize", +] + +[[package]] +name = "tls_codec_derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e00e3e7a54e0f1c8834ce72ed49c8487fbd3f801d8cfe1a0ad0640382f8e15" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.42", +] + [[package]] name = "tokio" version = "1.35.1" @@ -2582,6 +2563,23 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -3033,6 +3031,15 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +[[package]] +name = "winnow" +version = "0.5.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -3045,14 +3052,14 @@ dependencies = [ [[package]] name = "x509-cert" -version = "0.1.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d224a125dec5adda27d0346b9cae9794830279c4f9c27e4ab0b6c408d54012" +checksum = "1301e935010a701ae5f8655edc0ad17c44bad3ac5ce8c39185f75453b720ae94" dependencies = [ "const-oid", - "der 0.6.1", - "flagset", - "spki 0.6.0", + "der", + "spki", + "tls_codec", ] [[package]] @@ -3080,3 +3087,17 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.42", +] diff --git a/Cargo.toml b/Cargo.toml index bc24ef0..6ce0022 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ log = { version = "0.4", features = ["serde"] } log-panics = { version = "2", features = ["with-backtrace"] } # SSLv3 async impl -blaze-ssl-async = "^0.3" +blaze-ssl-async = "^0.4" # Resource embedding embeddy = "0.1" diff --git a/src/services/retriever/mod.rs b/src/services/retriever/mod.rs index 1e5f74b..3131033 100644 --- a/src/services/retriever/mod.rs +++ b/src/services/retriever/mod.rs @@ -10,7 +10,7 @@ use crate::{ }, utils::components::redirector, }; -use blaze_ssl_async::{stream::BlazeStream, BlazeError}; +use blaze_ssl_async::BlazeStream; use futures_util::{SinkExt, StreamExt}; use log::{debug, error, log_enabled}; use models::InstanceRequest; @@ -71,7 +71,7 @@ pub enum InstanceError { #[error("Failed to lookup server response empty")] MissingValue, #[error("Failed to connect to server: {0}")] - Blaze(#[from] BlazeError), + Io(#[from] std::io::Error), #[error("Failed to retrieve instance: {0}")] InstanceRequest(#[from] RetrieverError), #[error("Server response missing address")] @@ -299,7 +299,7 @@ pub type RetrieverResult = Result; impl OfficialSession { /// Creates a session with an official server at the provided /// `host` and `port` - async fn connect(host: &str, port: Port) -> Result { + async fn connect(host: &str, port: Port) -> std::io::Result { let stream = BlazeStream::connect((host, port)).await?; Ok(Self { id: 0,