Skip to content

Commit 98d35d3

Browse files
poelzitustvold
andauthored
Add ClientOption.allow_insecure (#3600)
* Add ClientOption.allow_insecure Add option to allow insecure https connections. In local isolated test environments, it is normal to use self signed, local certificates for automated integration testing. * clarify with_allow_invalid_certificates Co-authored-by: Raphael Taylor-Davies <[email protected]> Co-authored-by: Raphael Taylor-Davies <[email protected]>
1 parent bf21ad9 commit 98d35d3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

object_store/src/client/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub struct ClientOptions {
5252
default_headers: Option<HeaderMap>,
5353
proxy_url: Option<String>,
5454
allow_http: bool,
55+
allow_insecure: bool,
5556
timeout: Option<Duration>,
5657
connect_timeout: Option<Duration>,
5758
pool_idle_timeout: Option<Duration>,
@@ -106,6 +107,21 @@ impl ClientOptions {
106107
self.allow_http = allow_http;
107108
self
108109
}
110+
/// Allows connections to invalid SSL certificates
111+
/// * false (default): Only valid HTTPS certificates are allowed
112+
/// * true: All HTTPS certificates are allowed
113+
///
114+
/// # Warning
115+
///
116+
/// You should think very carefully before using this method. If
117+
/// invalid certificates are trusted, *any* certificate for *any* site
118+
/// will be trusted for use. This includes expired certificates. This
119+
/// introduces significant vulnerabilities, and should only be used
120+
/// as a last resort or for testing
121+
pub fn with_allow_invalid_certificates(mut self, allow_insecure: bool) -> Self {
122+
self.allow_insecure = allow_insecure;
123+
self
124+
}
109125

110126
/// Only use http1 connections
111127
pub fn with_http1_only(mut self) -> Self {
@@ -259,6 +275,10 @@ impl ClientOptions {
259275
builder = builder.http2_prior_knowledge()
260276
}
261277

278+
if self.allow_insecure {
279+
builder = builder.danger_accept_invalid_certs(self.allow_insecure)
280+
}
281+
262282
builder
263283
.https_only(!self.allow_http)
264284
.build()

0 commit comments

Comments
 (0)