From 554ab9dfda120e036bb3a8ce31d4c4ba4e096a58 Mon Sep 17 00:00:00 2001 From: Zeying Zhu Date: Mon, 20 Apr 2026 09:46:05 -0400 Subject: [PATCH] chore(tls): switch reqwest from native-tls to rustls for portable container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Why The Dockerfile was pinned to whichever Ubuntu matched the host build's libssl version — 20.04 (libssl1.1) on the current build host, 24.04 (libssl3) otherwise. Neither option is stable: the host toolchain can change and the base image has to follow it. Upgrading to Ubuntu 24.04 while the host still built on 20.04 produced the `libssl.so.1.1: cannot open shared object file` crash the last e2e hit inside the container. ## What `reqwest` is the only crate in this workspace pulling native TLS (through `hyper-tls` → `native-tls` → `openssl-sys`). Swap its feature set so it uses `rustls-tls` instead: - `asap-query-engine/Cargo.toml`: `default-features = false, features = ["json", "rustls-tls"]` - `asap-planner-rs/Cargo.toml`: same + `blocking` kept `rustls-tls` bundles Mozilla's root CA list via `webpki-roots`, so no `libssl*` / `ca-certificates` is needed at runtime for outbound HTTPS. No source-level change; the one reqwest call site already passes through `reqwest::Client::builder()`. `ldd target/release/query_engine_rust` on the rebuilt binary shows only libstdc++, libz, libgcc_s, libpthread, libm, libdl, libc — no libssl, no libcrypto. The binary runs unmodified on any glibc-2.31+ base (Ubuntu 20.04 through 24.04, Debian 11+). ## Dockerfile Updated `asap-quickstart/Dockerfile.queryengine-local` to drop `libssl3` from the apt install list (`ca-certificates` kept as a belt-and-suspenders for unusual CA chains, `zlib1g` for the snappy-less paths). Base stays on `ubuntu:24.04` — we can now bump it without tracking the host toolchain. ## Validation - `cargo test -p query_engine_rust --lib` — 723 pass (baseline) - `cargo clippy --all-targets -- -D warnings` — clean - `cargo fmt --all -- --check` — clean - `cargo build --release -p query_engine_rust` — succeeds - `cargo build -p asap_planner` — succeeds Co-Authored-By: Claude Opus 4.7 (1M context) --- Cargo.lock | 210 +++++++------------ asap-planner-rs/Cargo.toml | 2 +- asap-query-engine/Cargo.toml | 2 +- asap-quickstart/Dockerfile.queryengine-local | 12 +- 4 files changed, 88 insertions(+), 138 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d7b92515..87215c65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -965,16 +965,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-foundation" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -1840,21 +1830,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" -[[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.2.2" @@ -2258,6 +2233,20 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.32", + "rustls", + "tokio", + "tokio-rustls", +] + [[package]] name = "hyper-timeout" version = "0.5.2" @@ -2271,19 +2260,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.32", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-util" version = "0.1.20" @@ -2931,23 +2907,6 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" -[[package]] -name = "native-tls" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -3126,50 +3085,6 @@ version = "11.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" -[[package]] -name = "openssl" -version = "0.10.76" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" -dependencies = [ - "bitflags 2.11.0", - "cfg-if", - "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.117", -] - -[[package]] -name = "openssl-probe" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" - -[[package]] -name = "openssl-sys" -version = "0.9.112" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "ordered-float" version = "2.10.1" @@ -3960,15 +3875,15 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.32", - "hyper-tls", + "hyper-rustls", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls", "rustls-pemfile", "serde", "serde_json", @@ -3976,15 +3891,30 @@ dependencies = [ "sync_wrapper 0.1.2", "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots", "winreg", ] +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + [[package]] name = "rmp" version = "0.8.15" @@ -4040,6 +3970,18 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -4049,6 +3991,16 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.22" @@ -4070,15 +4022,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -4092,26 +4035,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" [[package]] -name = "security-framework" -version = "3.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" -dependencies = [ - "bitflags 2.11.0", - "core-foundation 0.10.1", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.17.0" +name = "sct" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "core-foundation-sys", - "libc", + "ring", + "untrusted", ] [[package]] @@ -4528,7 +4458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation 0.9.4", + "core-foundation", "system-configuration-sys", ] @@ -4736,12 +4666,12 @@ dependencies = [ ] [[package]] -name = "tokio-native-tls" -version = "0.3.1" +name = "tokio-rustls" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "native-tls", + "rustls", "tokio", ] @@ -5043,6 +4973,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.8" @@ -5271,6 +5207,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + [[package]] name = "winapi" version = "0.3.9" diff --git a/asap-planner-rs/Cargo.toml b/asap-planner-rs/Cargo.toml index abeaf025..802b916d 100644 --- a/asap-planner-rs/Cargo.toml +++ b/asap-planner-rs/Cargo.toml @@ -27,7 +27,7 @@ clap.workspace = true indexmap.workspace = true chrono.workspace = true promql-parser = "0.5.0" -reqwest = { version = "0.11", features = ["blocking", "json"] } +reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "rustls-tls"] } [dev-dependencies] tempfile = "3.20" diff --git a/asap-query-engine/Cargo.toml b/asap-query-engine/Cargo.toml index e45f4c39..2261aa4f 100644 --- a/asap-query-engine/Cargo.toml +++ b/asap-query-engine/Cargo.toml @@ -60,7 +60,7 @@ regex = "1" prometheus = "0.13" lazy_static = "1.4" zstd = "0.13" -reqwest = { version = "0.11", features = ["json"] } +reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] } tracing-appender = "0.2" elastic_dsl_utilities.workspace = true asap_sketchlib = { git = "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/ProjectASAP/asap_sketchlib" } diff --git a/asap-quickstart/Dockerfile.queryengine-local b/asap-quickstart/Dockerfile.queryengine-local index 1988f35c..beb1f137 100644 --- a/asap-quickstart/Dockerfile.queryengine-local +++ b/asap-quickstart/Dockerfile.queryengine-local @@ -1,10 +1,18 @@ -# Lightweight image that copies a pre-built query engine binary +# Lightweight image that copies a pre-built query engine binary. +# +# `reqwest` was switched to rustls-tls (see query_engine_rust/Cargo.toml +# and asap-planner-rs/Cargo.toml), so the binary no longer links against +# libssl at runtime. Any modern glibc base (Ubuntu 22.04+ or Debian 12+) +# works; we pin the LTS 24.04 for a stable default. `ca-certificates` +# is only needed if outbound TLS is made to hosts whose leaf certs +# aren't chained via webpki-roots — rustls-tls embeds Mozilla's bundle, +# so it's belt-and-suspenders for the common case. FROM ubuntu:24.04 WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates libssl3 zlib1g \ + ca-certificates zlib1g \ && rm -rf /var/lib/apt/lists/* COPY asap-quickstart/bin/query_engine_rust /usr/local/bin/query_engine_rust