From 7f45021afbd10671901d38a97a1142fe24b23593 Mon Sep 17 00:00:00 2001 From: asonix Date: Mon, 16 Mar 2020 13:27:42 -0500 Subject: [PATCH] Use rustls --- Cargo.lock | 173 +++++++++++++++++++++++++++++++--------------------- Cargo.toml | 2 +- src/db.rs | 6 ++ src/main.rs | 1 - 4 files changed, 110 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 385b5ee..b7899a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,10 +81,11 @@ dependencies = [ "futures", "http", "log", - "openssl", - "tokio-openssl", + "rustls", + "tokio-rustls", "trust-dns-proto", "trust-dns-resolver", + "webpki", ] [[package]] @@ -243,8 +244,10 @@ dependencies = [ "either", "futures", "log", - "openssl", - "tokio-openssl", + "rustls", + "tokio-rustls", + "webpki", + "webpki-roots", ] [[package]] @@ -292,9 +295,9 @@ dependencies = [ "log", "mime", "net2", - "openssl", "pin-project", "regex", + "rustls", "serde", "serde_json", "serde_urlencoded", @@ -454,9 +457,9 @@ dependencies = [ "futures-core", "log", "mime", - "openssl", "percent-encoding", "rand", + "rustls", "serde", "serde_json", "serde_urlencoded", @@ -834,21 +837,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -1161,6 +1149,15 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +[[package]] +name = "js-sys" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cb931d43e71f560c81badb0191596562bafad2be06a3f9025b845c847c60df5" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -1414,33 +1411,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -[[package]] -name = "openssl" -version = "0.10.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "973293749822d7dd6370d6da1e523b0d1db19f06c459134c658b2a4261378b52" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[package]] -name = "openssl-sys" -version = "0.9.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1024c0a59774200a555087a6da3f253a9095a5f344e353b212ac4c8b8e450986" -dependencies = [ - "autocfg 1.0.0", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "parking_lot" version = "0.10.0" @@ -1532,12 +1502,6 @@ version = "0.1.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -[[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" - [[package]] name = "postgres-protocol" version = "0.5.0" @@ -1700,6 +1664,21 @@ dependencies = [ "quick-error", ] +[[package]] +name = "ring" +version = "0.16.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "741ba1704ae21999c00942f9f5944f801e977f54302af346b596287599ad1862" +dependencies = [ + "cc", + "lazy_static", + "libc", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.8", +] + [[package]] name = "rsa" version = "0.2.0" @@ -1758,6 +1737,19 @@ dependencies = [ "semver", ] +[[package]] +name = "rustls" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" +dependencies = [ + "base64 0.11.0", + "log", + "ring", + "sct", + "webpki", +] + [[package]] name = "rustversion" version = "1.0.2" @@ -1781,6 +1773,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "semver" version = "0.9.0" @@ -2131,16 +2133,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "tokio-openssl" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c4b08c5f4208e699ede3df2520aca2e82401b2de33f45e96696a074480be594" -dependencies = [ - "openssl", - "tokio", -] - [[package]] name = "tokio-postgres" version = "0.5.3" @@ -2163,6 +2155,18 @@ dependencies = [ "tokio-util 0.3.0", ] +[[package]] +name = "tokio-rustls" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4adb8b3e5f86b707f1b54e7c15b6de52617a823608ccda98a15d3a24222f265a" +dependencies = [ + "futures-core", + "rustls", + "tokio", + "webpki", +] + [[package]] name = "tokio-util" version = "0.2.0" @@ -2276,6 +2280,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +[[package]] +name = "untrusted" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" + [[package]] name = "url" version = "2.1.1" @@ -2296,12 +2306,6 @@ dependencies = [ "rand", ] -[[package]] -name = "vcpkg" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2362,6 +2366,35 @@ version = "0.2.59" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8" +[[package]] +name = "web-sys" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f50e1972865d6b1adb54167d1c8ed48606004c2c9d0ea5f1eeb34d95e863ef" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" +dependencies = [ + "webpki", +] + [[package]] name = "widestring" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 69d2c53..6859a94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" anyhow = "1.0" actix = "0.10.0-alpha.2" actix-rt = "1.0.0" -actix-web = { version = "3.0.0-alpha.1", features = ["openssl"] } +actix-web = { version = "3.0.0-alpha.1", features = ["rustls"] } actix-webfinger = { version = "0.3.0-alpha.2" } activitystreams = "0.5.0-alpha.7" base64 = "0.12" diff --git a/src/db.rs b/src/db.rs index b37906d..62a1118 100644 --- a/src/db.rs +++ b/src/db.rs @@ -11,6 +11,12 @@ use std::collections::HashSet; pub struct HostError; pub async fn listen(client: &Client) -> Result<(), Error> { + info!("LISTEN new_blocks;"); + info!("LISTEN new_whitelists;"); + info!("LISTEN new_listeners;"); + info!("LISTEN rm_blocks;"); + info!("LISTEN rm_whitelists;"); + info!("LISTEN rm_listeners;"); client .batch_execute( "LISTEN new_blocks; diff --git a/src/main.rs b/src/main.rs index b40f81c..02db406 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,7 +64,6 @@ async fn actor_route(state: web::Data) -> Result #[actix_rt::main] async fn main() -> Result<(), anyhow::Error> { dotenv::dotenv().ok(); - std::env::set_var("RUST_LOG", "debug"); pretty_env_logger::init(); let pg_config: tokio_postgres::Config = std::env::var("DATABASE_URL")?.parse()?;