From dca80419902d71709fc4950a22c98d1b1cc2f382 Mon Sep 17 00:00:00 2001 From: alice Date: Wed, 17 May 2023 11:30:59 +0200 Subject: [PATCH] feat(deps): allow using openssl for tls (#37) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(deps): allow using openssl for tls this allows reusing the openssl present on a distro already, and takes a release build with it from 5.5 to 4.7mb * chore(shuttle): update the enabled features for deployment --------- Co-authored-by: Orhun Parmaksız --- .github/workflows/shuttle.yml | 2 +- Cargo.lock | 74 +++++++++++++++++++++++++++++++++++ Cargo.toml | 8 ++-- 3 files changed, 80 insertions(+), 4 deletions(-) diff --git a/.github/workflows/shuttle.yml b/.github/workflows/shuttle.yml index 63442a7..0d250e9 100644 --- a/.github/workflows/shuttle.yml +++ b/.github/workflows/shuttle.yml @@ -24,7 +24,7 @@ jobs: run: cargo binstall -y cargo-shuttle - name: Prepare for deployment shell: bash - run: sed -i 's|default = \[\]|default = \["shuttle"\]|g' Cargo.toml + run: sed -i 's|default = \["rustls"\]|default = \["rustls", "shuttle"\]|g' Cargo.toml - name: Login run: cargo shuttle login --api-key ${{ secrets.SHUTTLE_TOKEN }} - name: Restart diff --git a/Cargo.lock b/Cargo.lock index 15ff787..c3a3d0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,7 +196,9 @@ dependencies = [ "futures-core", "http", "log", + "openssl", "pin-project-lite", + "tokio-openssl", "tokio-rustls", "tokio-util", "webpki-roots", @@ -459,6 +461,7 @@ dependencies = [ "itoa", "log", "mime", + "openssl", "percent-encoding", "pin-project-lite", "rand", @@ -953,6 +956,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[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 = "form_urlencoded" version = "1.1.0" @@ -1793,6 +1811,44 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "openssl" +version = "0.10.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01b8574602df80f7b85fdfc5392fa884a4e3b3f4f35402c070ab34c3d3f78d56" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.15", +] + +[[package]] +name = "openssl-sys" +version = "0.9.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "opentelemetry" version = "0.18.0" @@ -2834,6 +2890,18 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "tokio-openssl" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08f9ffb7809f1b20c1b398d92acf4cc719874b3b2b2d9ea2f09b4a80350878a" +dependencies = [ + "futures-util", + "openssl", + "openssl-sys", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.23.4" @@ -3158,6 +3226,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index dc108e8..2f613c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,9 @@ categories = ["web-programming::http-server"] include = ["src/**/*", "Cargo.*", "LICENSE", "README.md", "CHANGELOG.md"] [features] -default = [] +default = ["rustls"] +openssl = ["actix-web/openssl", "awc/openssl"] +rustls = ["actix-web/rustls", "awc/rustls"] shuttle = [ "dep:shuttle-actix-web", "dep:shuttle-runtime", @@ -22,10 +24,10 @@ shuttle = [ ] [dependencies] -actix-web = { version = "4.3.1", features = ["rustls"] } +actix-web = { version = "4.3.1" } actix-multipart = "0.6.0" actix-files = "0.6.2" -awc = { version = "3.1.1", features = ["rustls"] } +awc = { version = "3.1.1" } env_logger = "0.10.0" log = "0.4.17" serde = "1.0.163"