Skip to content

Commit

Permalink
feat: add cargo features for tls options (#61)
Browse files Browse the repository at this point in the history
Adds features to switch native-tls, rustls-tls or disable tls at all
  • Loading branch information
yaozongyou authored Oct 25, 2024
1 parent 2ce4fef commit eae6502
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ readme = "README.md"
keywords = ["object-storage", "minio", "s3"]
categories = ["api-bindings", "web-programming::http-client"]

[dependencies.reqwest]
version = "0.12.5"
default-features = false
features = ["stream"]

[features]
default = ["default-tls"]
default-tls = ["reqwest/default-tls"]
native-tls = ["reqwest/native-tls"]
rustls-tls = ["reqwest/rustls-tls"]

[dependencies]
async-recursion = "1.0.4"
async-trait = "0.1.73"
Expand All @@ -35,7 +46,6 @@ os_info = "3.7.0"
percent-encoding = "2.3.0"
rand = { version = "0.8.5", features = ["small_rng"] }
regex = "1.9.4"
reqwest = { version = "0.12.5", features = ["native-tls", "blocking", "rustls-tls", "stream"] }
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.105"
sha2 = "0.10.7"
Expand All @@ -45,7 +55,6 @@ tokio-util = { version = "0.7.8", features = ["io"] }
urlencoding = "2.1.3"
xmltree = "0.10.3"


[dev-dependencies]
async-std = { version = "1.12.0", features = ["attributes", "tokio1"] }
clap = { version = "4.5.4", features = ["derive"] }
Expand Down
10 changes: 10 additions & 0 deletions src/s3/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,20 @@ impl ClientBuilder {
}
builder = builder.user_agent(user_agent);

#[cfg(any(
feature = "default-tls",
feature = "native-tls",
feature = "rustls-tls"
))]
if let Some(v) = self.ignore_cert_check {
builder = builder.danger_accept_invalid_certs(v);
}

#[cfg(any(
feature = "default-tls",
feature = "native-tls",
feature = "rustls-tls"
))]
if let Some(v) = self.ssl_cert_file {
let mut buf = Vec::new();
File::open(v)?.read_to_end(&mut buf)?;
Expand Down

0 comments on commit eae6502

Please sign in to comment.