From a041d405f83016e6e6453d40ffec30494063cdc0 Mon Sep 17 00:00:00 2001 From: Daniel Turner Date: Mon, 8 Aug 2022 13:21:56 +0100 Subject: [PATCH 1/2] native tls --- Cargo.lock | 136 +++++++++++++++++++++++++++++++++++++++++++++++----- Cargo.toml | 4 +- src/main.rs | 13 ++--- 3 files changed, 133 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c21e51..1edabd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,9 +21,9 @@ dependencies = [ "fake", "itertools", "lazy_static", - "openssl", + "native-tls", "postgres", - "postgres-openssl", + "postgres-native-tls", "pretty_assertions", "rand", "regex", @@ -155,6 +155,22 @@ dependencies = [ "vec_map", ] +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpufeatures" version = "0.2.2" @@ -222,6 +238,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + [[package]] name = "foreign-types" version = "0.3.2" @@ -374,6 +399,15 @@ dependencies = [ "digest", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "itertools" version = "0.10.3" @@ -447,6 +481,24 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "native-tls" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -498,6 +550,12 @@ dependencies = [ "syn", ] +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + [[package]] name = "openssl-sys" version = "0.9.75" @@ -600,15 +658,15 @@ dependencies = [ ] [[package]] -name = "postgres-openssl" +name = "postgres-native-tls" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de0ea6504e07ca78355a6fb88ad0f36cafe9e696cbc6717f16a207f3a60be72" +checksum = "2d442770e2b1e244bb5eb03b31c79b65bb2568f413b899eaba850fa945a65954" dependencies = [ "futures", - "openssl", + "native-tls", "tokio", - "tokio-openssl", + "tokio-native-tls", "tokio-postgres", ] @@ -757,18 +815,60 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + [[package]] name = "ryu" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys", +] + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "security-framework" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "serde" version = "1.0.140" @@ -899,6 +999,20 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -952,14 +1066,12 @@ dependencies = [ ] [[package]] -name = "tokio-openssl" -version = "0.6.3" +name = "tokio-native-tls" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08f9ffb7809f1b20c1b398d92acf4cc719874b3b2b2d9ea2f09b4a80350878a" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" dependencies = [ - "futures-util", - "openssl", - "openssl-sys", + "native-tls", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 5364ae4..2fac80c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,9 @@ chrono = "0.4" itertools = "0.10.1" fake = "2.4" lazy_static = "1.4.0" -openssl = "0.10.41" +native-tls = "0.2.10" postgres = "0.19.2" -postgres-openssl = "0.5.0" +postgres-native-tls = "0.5.0" rand = "0.8" regex = "1" serde_json = "1.0" diff --git a/src/main.rs b/src/main.rs index 5ce14a7..0bb9de7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,9 +8,11 @@ use crate::opts::{Anonymiser, Opts}; use crate::parsers::strategies::Strategies; use crate::parsers::strategy_structs::{MissingColumns, SimpleColumn, TransformerOverrides}; use itertools::Itertools; -use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; +use native_tls::TlsConnector; +use postgres_native_tls::MakeTlsConnector; + use parsers::{db_schema, strategy_file}; -use postgres_openssl::MakeTlsConnector; +//use postgres_openssl::MakeTlsConnector; use structopt::StructOpt; fn main() -> Result<(), std::io::Error> { @@ -138,10 +140,9 @@ fn missing_to_message(missing: &[SimpleColumn]) -> String { } fn strategy_differences(strategies: &Strategies, db_url: String) -> Result<(), MissingColumns> { - let mut builder = - SslConnector::builder(SslMethod::tls()).expect("expected to build tls connector!"); - builder.set_verify(SslVerifyMode::PEER); - let connector = MakeTlsConnector::new(builder.build()); + let builder = TlsConnector::builder(); + let connector = + MakeTlsConnector::new(builder.build().expect("should be able to create builder!")); let mut client = postgres::Client::connect(&db_url, connector).expect("expected to connect!"); let db_columns = db_schema::parse(&mut client); From aa40095502c311f12919b28f03c988329a11c2d7 Mon Sep 17 00:00:00 2001 From: Daniel Turner Date: Mon, 8 Aug 2022 13:23:17 +0100 Subject: [PATCH 2/2] remove comment --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0bb9de7..85fd9f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,6 @@ use native_tls::TlsConnector; use postgres_native_tls::MakeTlsConnector; use parsers::{db_schema, strategy_file}; -//use postgres_openssl::MakeTlsConnector; use structopt::StructOpt; fn main() -> Result<(), std::io::Error> {