Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create macOS release builds with bundled root certificates #272

Merged
merged 1 commit into from
May 6, 2022

Conversation

dbrgn
Copy link
Collaborator

@dbrgn dbrgn commented May 3, 2022

As reported in #244, some users on macOS had problems with rustls-tls-native-roots. Since we did not find the root cause of this, we'll build macOS release builds with rustls-tls-webpki-roots instead.

I first tried to solve this issue with default features and conditional dependencies in Cargo.toml, but ultimately gave up and resorted to sed.

Fixes #244.

@dbrgn dbrgn added the chore label May 3, 2022
@dbrgn dbrgn requested a review from niklasmohrin May 3, 2022 20:55
@dbrgn dbrgn self-assigned this May 3, 2022
@dbrgn dbrgn force-pushed the macos-bundled-trust-store branch from 58f2419 to 1403f42 Compare May 3, 2022 21:03
@niklasmohrin
Copy link
Collaborator

I think this works:

diff --git a/Cargo.toml b/Cargo.toml
index 6752a3b..1f8cf5c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,7 @@ atty = "0.2"
 clap = { version = "3", features = ["std", "derive", "suggestions", "color"], default-features = false }
 env_logger = { version = "0.9", optional = true }
 log = "0.4"
-reqwest = { version = "0.11.3", features = ["blocking", "rustls-tls", "rustls-tls-native-roots"], default-features = false }
+reqwest = { version = "0.11.3", features = ["blocking", "rustls-tls"], default-features = false }
 serde = "1.0.21"
 serde_derive = "1.0.21"
 toml = "0.5.1"
@@ -44,6 +44,9 @@ tempfile = "3.1.0"
 filetime = "0.2.10"
 
 [features]
+default = ["native-roots"]
+native-roots = ["reqwest/rustls-tls-native-roots"]
+webpki-roots = ["reqwest/rustls-tls-webpki-roots"]
 logging = ["env_logger"]
 
 [profile.release]
diff --git a/src/main.rs b/src/main.rs
index 216c349..4350f04 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,6 +16,11 @@
 #![allow(clippy::struct_excessive_bools)]
 #![allow(clippy::too_many_lines)]
 
+#[cfg(all(feature = "native-roots", feature = "webpki-roots"))]
+compile_error!(
+    "feature \"native-roots\" and feature \"webpki-roots\" cannot be enabled at the same time"
+);
+
 use std::{env, process};
 
 use app_dirs::AppInfo;

Check with cargo tree -e features -i reqwest --features webpki-roots --no-default-features

@dbrgn dbrgn force-pushed the macos-bundled-trust-store branch from 1403f42 to 6e84290 Compare May 5, 2022 21:23
@dbrgn
Copy link
Collaborator Author

dbrgn commented May 5, 2022

Updated! I also had to fix all usage of --all-features as well as adding an assertion that at least one of the two features is defined (otherwise updating will fail at runtime).

@dbrgn dbrgn force-pushed the macos-bundled-trust-store branch from 6e84290 to e3edbff Compare May 5, 2022 22:08
As reported in #244, some users
on macOS had problems with `rustls-tls-native-roots`. Since we did not
find the root cause of this, we'll build macOS release builds with
`rustls-tls-webpki-roots` instead.
@dbrgn dbrgn force-pushed the macos-bundled-trust-store branch from e3edbff to 304c2a9 Compare May 6, 2022 10:35
@dbrgn dbrgn enabled auto-merge (squash) May 6, 2022 10:41
@dbrgn dbrgn merged commit 0f82aa5 into main May 6, 2022
@dbrgn dbrgn deleted the macos-bundled-trust-store branch May 6, 2022 11:38
@dbrgn dbrgn mentioned this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

macOS panicks with --update: MissingOrMalformedExtensions
2 participants