Skip to content

Commit

Permalink
Allow building with native-tls
Browse files Browse the repository at this point in the history
Right now we only support building with Rustls. However, there are quite
a few architectures that aren't yet supported by "ring" (the crypto
library used by Rustls), for example MIPS, PowerPC or SPARC.

To offer an alternative, I added the "native-tls" feature that can be
used instead of "native-roots". When used, the native TLS stack is used
instead of Rustls (i.e. SChannel on Windows, Secure Transport on macOS
and OpenSSL otherwise).
  • Loading branch information
dbrgn committed Dec 11, 2022
1 parent 76bb4e7 commit 3652f2a
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 2 deletions.
110 changes: 110 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ filetime = "0.2.10"

[features]
default = ["native-roots"]
# Use Rustls with native roots
native-roots = ["reqwest/rustls-tls-native-roots"]
# Use Rustls with WebPK roots
webpki-roots = ["reqwest/rustls-tls-webpki-roots"]
# Use native TLS (SChannel on Windows, Secure Transport on macOS and OpenSSL otherwise)
native-tls = ["reqwest/native-tls"]
logging = ["env_logger"]

[profile.release]
Expand Down
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@
#![allow(clippy::too_many_lines)]

#[cfg(any(
all(
feature = "native-roots",
feature = "webpki-roots",
feature = "native-tls"
),
all(feature = "native-roots", feature = "webpki-roots"),
not(any(feature = "native-roots", feature = "webpki-roots")),
all(feature = "native-roots", feature = "native-tls"),
all(feature = "webpki-roots", feature = "native-tls"),
not(any(
feature = "native-roots",
feature = "webpki-roots",
feature = "native-tls"
)),
))]
compile_error!(
"exactly one of feature \"native-roots\" and feature \"webpki-roots\" must be enabled"
"exactly one of features \"native-roots\", \"webpki-roots\" or \"native-tls\" must be enabled"
);

use std::{env, process};
Expand Down

0 comments on commit 3652f2a

Please sign in to comment.