Skip to content

Commit 1fbd90e

Browse files
committed
Use path-style URL in resolve_bucket_region for dotted bucket names
S3's wildcard TLS cert (*.s3.amazonaws.com) only covers one DNS label. Use path-style for bucket names containing dots. Closes #747
1 parent 2e859ee commit 1fbd90e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/aws/resolve.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ impl From<Error> for crate::Error {
4949
pub async fn resolve_bucket_region(bucket: &str, client_options: &ClientOptions) -> Result<String> {
5050
use http::StatusCode;
5151

52-
let endpoint = format!("https://{bucket}.s3.amazonaws.com");
52+
// S3's wildcard TLS cert (*.s3.amazonaws.com) only covers one DNS label. Use path-style for dotted names.
53+
let endpoint = if bucket.contains('.') {
54+
format!("https://s3.amazonaws.com/{bucket}")
55+
} else {
56+
format!("https://{bucket}.s3.amazonaws.com")
57+
};
5358

5459
let client = client_options.client()?;
5560

0 commit comments

Comments
 (0)