Use rustls

This commit is contained in:
asonix 2020-03-16 13:27:42 -05:00
parent b7bf001287
commit 7f45021afb
4 changed files with 110 additions and 72 deletions

173
Cargo.lock generated
View file

@ -81,10 +81,11 @@ dependencies = [
"futures", "futures",
"http", "http",
"log", "log",
"openssl", "rustls",
"tokio-openssl", "tokio-rustls",
"trust-dns-proto", "trust-dns-proto",
"trust-dns-resolver", "trust-dns-resolver",
"webpki",
] ]
[[package]] [[package]]
@ -243,8 +244,10 @@ dependencies = [
"either", "either",
"futures", "futures",
"log", "log",
"openssl", "rustls",
"tokio-openssl", "tokio-rustls",
"webpki",
"webpki-roots",
] ]
[[package]] [[package]]
@ -292,9 +295,9 @@ dependencies = [
"log", "log",
"mime", "mime",
"net2", "net2",
"openssl",
"pin-project", "pin-project",
"regex", "regex",
"rustls",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
@ -454,9 +457,9 @@ dependencies = [
"futures-core", "futures-core",
"log", "log",
"mime", "mime",
"openssl",
"percent-encoding", "percent-encoding",
"rand", "rand",
"rustls",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
@ -834,21 +837,6 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" 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]] [[package]]
name = "fuchsia-zircon" name = "fuchsia-zircon"
version = "0.3.3" version = "0.3.3"
@ -1161,6 +1149,15 @@ version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" 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]] [[package]]
name = "kernel32-sys" name = "kernel32-sys"
version = "0.2.2" version = "0.2.2"
@ -1414,33 +1411,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" 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]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.10.0" version = "0.10.0"
@ -1532,12 +1502,6 @@ version = "0.1.0-alpha.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587"
[[package]]
name = "pkg-config"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
[[package]] [[package]]
name = "postgres-protocol" name = "postgres-protocol"
version = "0.5.0" version = "0.5.0"
@ -1700,6 +1664,21 @@ dependencies = [
"quick-error", "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]] [[package]]
name = "rsa" name = "rsa"
version = "0.2.0" version = "0.2.0"
@ -1758,6 +1737,19 @@ dependencies = [
"semver", "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]] [[package]]
name = "rustversion" name = "rustversion"
version = "1.0.2" version = "1.0.2"
@ -1781,6 +1773,16 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 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]] [[package]]
name = "semver" name = "semver"
version = "0.9.0" version = "0.9.0"
@ -2131,16 +2133,6 @@ dependencies = [
"winapi 0.3.8", "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]] [[package]]
name = "tokio-postgres" name = "tokio-postgres"
version = "0.5.3" version = "0.5.3"
@ -2163,6 +2155,18 @@ dependencies = [
"tokio-util 0.3.0", "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]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.2.0" version = "0.2.0"
@ -2276,6 +2280,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "untrusted"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece"
[[package]] [[package]]
name = "url" name = "url"
version = "2.1.1" version = "2.1.1"
@ -2296,12 +2306,6 @@ dependencies = [
"rand", "rand",
] ]
[[package]]
name = "vcpkg"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.9.0+wasi-snapshot-preview1" 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" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8" 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]] [[package]]
name = "widestring" name = "widestring"
version = "0.4.0" version = "0.4.0"

View file

@ -10,7 +10,7 @@ edition = "2018"
anyhow = "1.0" anyhow = "1.0"
actix = "0.10.0-alpha.2" actix = "0.10.0-alpha.2"
actix-rt = "1.0.0" 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" } actix-webfinger = { version = "0.3.0-alpha.2" }
activitystreams = "0.5.0-alpha.7" activitystreams = "0.5.0-alpha.7"
base64 = "0.12" base64 = "0.12"

View file

@ -11,6 +11,12 @@ use std::collections::HashSet;
pub struct HostError; pub struct HostError;
pub async fn listen(client: &Client) -> Result<(), Error> { 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 client
.batch_execute( .batch_execute(
"LISTEN new_blocks; "LISTEN new_blocks;

View file

@ -64,7 +64,6 @@ async fn actor_route(state: web::Data<State>) -> Result<impl Responder, MyError>
#[actix_rt::main] #[actix_rt::main]
async fn main() -> Result<(), anyhow::Error> { async fn main() -> Result<(), anyhow::Error> {
dotenv::dotenv().ok(); dotenv::dotenv().ok();
std::env::set_var("RUST_LOG", "debug");
pretty_env_logger::init(); pretty_env_logger::init();
let pg_config: tokio_postgres::Config = std::env::var("DATABASE_URL")?.parse()?; let pg_config: tokio_postgres::Config = std::env::var("DATABASE_URL")?.parse()?;