From a2e432a9dc52b34875ac09aeef44ad7083b13c4c Mon Sep 17 00:00:00 2001 From: Peter Holloway Date: Mon, 13 Jan 2025 14:49:45 +0000 Subject: [PATCH] Bundle root certificates at compile time In order to make https connections for authorisation, the reqwuest library needs root certificates. In the minimal container used, these are not present in the OS so authorisation fails. By bundling them at compile time (via the webpki-roots crate) the native certificates are not required. This usually presents a maintenance burden as the application needs to be recompiled if root CA certificates change, however in the case where the application is running in a container, the container would need to be rebuilt in either case to include the new certificates. --- Cargo.lock | 73 ++++++++---------------------------------------------- Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d249e6a..42e94180 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -716,16 +716,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "core-foundation" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -1425,11 +1415,11 @@ dependencies = [ "hyper 1.5.2", "hyper-util", "rustls", - "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", "tower-service", + "webpki-roots", ] [[package]] @@ -1946,12 +1936,6 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - [[package]] name = "opentelemetry" version = "0.27.1" @@ -2455,7 +2439,6 @@ dependencies = [ "pin-project-lite", "quinn", "rustls", - "rustls-native-certs", "rustls-pemfile", "rustls-pki-types", "serde", @@ -2470,6 +2453,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots", "windows-registry", ] @@ -2586,18 +2570,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" -dependencies = [ - "openssl-probe", - "rustls-pki-types", - "schannel", - "security-framework", -] - [[package]] name = "rustls-pemfile" version = "2.2.0" @@ -2639,44 +2611,12 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" -[[package]] -name = "schannel" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "security-framework" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d3f8c9bfcc3cbb6b0179eb57042d75b1582bdc65c3cb95f3fa999509c03cbc" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.24" @@ -3730,6 +3670,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.26.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "whoami" version = "1.5.2" diff --git a/Cargo.toml b/Cargo.toml index 3355f25f..88356ceb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ opentelemetry-otlp = "0.27.0" opentelemetry-semantic-conventions = "0.27.0" opentelemetry-stdout = "0.27.0" opentelemetry_sdk = { version = "0.27.1", features = ["rt-tokio"] } -reqwest = { version = "0.12.7", features = ["json", "rustls-tls-native-roots"], default-features = false } +reqwest = { version = "0.12.7", features = ["json", "rustls-tls"], default-features = false } serde = { version = "1.0.210", features = ["derive"] } sqlx = { version = "0.8.2", features = ["runtime-tokio", "sqlite"] } tokio = { version = "1.42.0", features = ["full"] }