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 Feb 12, 2023
1 parent 0c8cb42 commit 150a79f
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 3 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.

13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,20 @@ filetime = "0.2.10"

[features]
default = ["native-roots"]
logging = ["env_logger"]

# Reqwest (the HTTP client library) can handle TLS connections in three
# different modes:
#
# - Rustls with native roots
# - Rustls with WebPK roots
# - Native TLS (SChannel on Windows, Secure Transport on macOS and OpenSSL otherwise)
#
# Exactly one of the three variants must be selected. By default, Rustls with
# native roots is enabled.
native-roots = ["reqwest/rustls-tls-native-roots"]
webpki-roots = ["reqwest/rustls-tls-webpki-roots"]
logging = ["env_logger"]
native-tls = ["reqwest/native-tls"]

[profile.release]
lto = true
10 changes: 8 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@

#[cfg(any(
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 the features \"native-roots\", \"webpki-roots\" or \"native-tls\" must be enabled"
);

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

0 comments on commit 150a79f

Please sign in to comment.