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

feat: allow multiple trust certs in cert file #102

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["object-storage", "minio", "s3"]
categories = ["api-bindings", "web-programming::http-client"]

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

Expand Down
12 changes: 8 additions & 4 deletions src/s3/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ impl ClientBuilder {
self
}

/// Set file for loading a trust certificate.
/// Set file for loading CAs certs to trust. This is in addition to the system
/// trust store. The file must contain PEM encoded certificates.
pub fn ssl_cert_file(mut self, ssl_cert_file: Option<&Path>) -> Self {
self.ssl_cert_file = ssl_cert_file.map(PathBuf::from);
self
}

/// Set flag to ignore certificate check.
/// Set flag to ignore certificate check. This is insecure and should only
/// be used for testing.
pub fn ignore_cert_check(mut self, ignore_cert_check: Option<bool>) -> Self {
self.ignore_cert_check = ignore_cert_check;
self
Expand Down Expand Up @@ -137,8 +139,10 @@ impl ClientBuilder {
if let Some(v) = self.ssl_cert_file {
let mut buf = Vec::new();
File::open(v)?.read_to_end(&mut buf)?;
let cert = reqwest::Certificate::from_pem(&buf)?;
builder = builder.add_root_certificate(cert);
let certs = reqwest::Certificate::from_pem_bundle(&buf)?;
for cert in certs {
builder = builder.add_root_certificate(cert);
}
}

let client = builder.build()?;
Expand Down