S3: Support for allowInvalidCerts option to allow connecting to S3 endpoints with invalid TLS certificates

This commit is contained in:
Maurus Decimus
2026-06-24 14:21:11 +02:00
parent 174f6b599c
commit d1dd00558f
4 changed files with 79 additions and 104 deletions

View File

@@ -13,6 +13,7 @@ rocksdb = { version = "0.24", optional = true, features = ["multi-threaded-cf"]
foundationdb = { version = "0.10", features = ["embedded-fdb-include", "fdb-7_4"], optional = true }
rusqlite = { version = "0.40", features = ["bundled"], optional = true }
rust-s3 = { version = "0.37", default-features = false, features = ["tokio-rustls-tls"], optional = true }
reqwest_s3 = { package = "reqwest", version = "0.12", default-features = false, features = ["rustls-tls-native-roots"], optional = true }
azure_core = { version = "0.21.0", optional = true }
azure_storage = { version = "0.21.0", default-features = false, features = ["enable_reqwest_rustls", "hmac_rust"], optional = true }
azure_storage_blobs = { version = "0.21.0", default-features = false, features = ["enable_reqwest_rustls", "hmac_rust"], optional = true }
@@ -50,7 +51,6 @@ bitpacking = "0.9.2"
memchr = { version = "2.7" }
rkyv = { version = "0.8.10", features = ["little_endian"] }
compact_str = "0.9.0"
rustls_021 = { package = "rustls", version = "0.21", default-features = false, features = ["dangerous_configuration"], optional = true }
gethostname = "1.1.0"
radsort = "0.1.1"
@@ -67,7 +67,7 @@ foundation = ["foundationdb", "futures"]
fdb-chunked-bm = []
# Blob stores
s3 = ["rust-s3", "rustls_021"]
s3 = ["rust-s3", "dep:reqwest_s3"]
azure = ["azure_core", "azure_storage", "azure_storage_blobs", "futures"]
# In-memory stores

View File

@@ -7,7 +7,7 @@
use crate::BlobStore;
use registry::schema::structs;
use s3::{Bucket, Region, creds::Credentials};
use std::{fmt::Display, io::Write, ops::Range, sync::Arc, time::Duration};
use std::{io::Write, ops::Range, sync::Arc, time::Duration};
use utils::codec::base32_custom::Base32Writer;
pub struct S3Store {
@@ -81,11 +81,8 @@ impl S3Store {
bucket: Bucket::new(&config.bucket, region, credentials)
.map_err(|err| format!("Failed to create bucket: {err:?}"))?
.with_path_style()
/*.set_dangereous_config(allow_invalid, allow_invalid)
.map_err(|err| {
format!("Failed to create bucket: {err:?}")
})
?*/
.set_dangerous_config(config.allow_invalid_certs, config.allow_invalid_certs)
.map_err(|err| format!("Failed to create bucket: {err:?}"))?
.with_request_timeout(config.timeout.into_inner())
.map_err(|err| format!("Failed to create bucket: {err:?}"))?,
max_retries: config.max_retries as u32,
@@ -247,7 +244,13 @@ impl S3Store {
}
}
#[inline(always)]
fn into_error(err: impl Display) -> trc::Error {
trc::StoreEvent::S3Error.reason(err)
fn into_error(err: impl std::error::Error) -> trc::Error {
let mut reason = err.to_string();
let mut source = err.source();
while let Some(err) = source {
reason.push_str(": ");
reason.push_str(&err.to_string());
source = err.source();
}
trc::StoreEvent::S3Error.reason(reason)
}