Skip to content

Commit

Permalink
check ONEIO_ACCEPT_INVALID_CERTS to disable ssl checking
Browse files Browse the repository at this point in the history
  • Loading branch information
digizeph committed Jul 23, 2024
1 parent 7ce32ab commit 3cae1a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,50 @@ path = "src/bin/oneio.rs"
required-features = ["cli"]

[dependencies]
# remote

# required dependency
dotenvy = "0.15"
thiserror = "1.0"

# feature: remote
reqwest = { version = "0.12", default-features = false, features = [
"blocking",
"http2",
"charset",
], optional = true }
suppaftp = { version = "6.0", optional = true }

# compression
# feature: compressions
flate2 = { version = "1", optional = true }
bzip2 = { version = "0.4.4", optional = true }
lz4 = { version = "1.24", optional = true }
xz2 = { version = "0.1", optional = true }
zstd = { version = "0.13.2", optional = true }

# sha256
# feature: digest
ring = { version = "0.17", optional = true }
hex = { version = "0.4", optional = true }

# cli
clap = { version = "4.4", features = ["derive"], optional = true }
tracing = { version = "0.1", optional = true }

# json
# feature: json
serde = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }

# s3
# feature: s3
rust-s3 = { version = "0.34.0-rc4", optional = true, default-features = false, features = [
"sync",
] }
dotenvy = { version = "0.15", optional = true }

# ftp
suppaftp = { version = "6.0", optional = true }
# feature: cli
clap = { version = "4.4", features = ["derive"], optional = true }
tracing = { version = "0.1", optional = true }

thiserror = "1.0"

[features]
# default features include the library core and use rustls by default
default = ["lib-core", "rustls"]

# library core dependency to enable reading from local/remote with compressions enabled
lib-core = ["remote", "compressions", "json"]

# cli dependencies
cli = [
# core dependency
Expand Down Expand Up @@ -98,7 +98,7 @@ remote = ["reqwest", "suppaftp"]
json = ["serde", "serde_json"]

# s3 support, off by default
s3 = ["rust-s3", "dotenvy"]
s3 = ["rust-s3"]

[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }
Expand Down
14 changes: 13 additions & 1 deletion src/oneio/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ fn get_http_reader_raw(
path: &str,
opt_client: Option<Client>,
) -> Result<reqwest::blocking::Response, OneIoError> {
dotenvy::dotenv().ok();
let accept_invalid_certs = matches!(
std::env::var("ONEIO_ACCEPT_INVALID_CERTS")
.unwrap_or_default()
.to_lowercase()
.as_str(),
"true" | "yes" | "y" | "1"
);

let client = match opt_client {
Some(c) => c,
None => {
Expand All @@ -52,7 +61,10 @@ fn get_http_reader_raw(
reqwest::header::CACHE_CONTROL,
reqwest::header::HeaderValue::from_static("no-cache"),
);
Client::builder().default_headers(headers).build()?
Client::builder()
.default_headers(headers)
.danger_accept_invalid_certs(accept_invalid_certs)
.build()?
}
};
let res = client
Expand Down

0 comments on commit 3cae1a0

Please sign in to comment.