aboutsummaryrefslogtreecommitdiff
path: root/src/consul.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-08-24 18:22:00 +0200
committerAlex Auvolat <alex@adnab.me>2022-08-24 18:22:00 +0200
commite7f6c15bc11ce04fdc3444f7bd1a588516e92dd9 (patch)
treea2e0a9c8c6652e170ef4aadc3d5b3953e58a7181 /src/consul.rs
parent730c9049ad79b15c3372cbd3737c5e90b311bd62 (diff)
downloaddiplonat-consul-tls.tar.gz
diplonat-consul-tls.zip
Add possibility to skip tls verification for consulconsul-tls
Diffstat (limited to 'src/consul.rs')
-rw-r--r--src/consul.rs29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/consul.rs b/src/consul.rs
index 4677931..c7ac2b6 100644
--- a/src/consul.rs
+++ b/src/consul.rs
@@ -23,13 +23,28 @@ pub struct Consul {
impl Consul {
pub fn new(config: &RuntimeConfigConsul) -> Self {
- let client = if let Some((ca, ident)) = config.tls.clone() {
- reqwest::Client::builder()
- .use_rustls_tls()
- .add_root_certificate(ca)
- .identity(ident)
- .build()
- .expect("Unable to build reqwest client")
+ let client = if let Some((ca, skip_verify, ident)) = config.tls.clone() {
+ if skip_verify {
+ reqwest::Client::builder()
+ .use_rustls_tls()
+ .danger_accept_invalid_certs(true)
+ .identity(ident)
+ .build()
+ .expect("Unable to build reqwest client")
+ } else if let Some(ca) = ca {
+ reqwest::Client::builder()
+ .use_rustls_tls()
+ .add_root_certificate(ca)
+ .identity(ident)
+ .build()
+ .expect("Unable to build reqwest client")
+ } else {
+ reqwest::Client::builder()
+ .use_rustls_tls()
+ .identity(ident)
+ .build()
+ .expect("Unable to build reqwest client")
+ }
} else {
reqwest::Client::new()
};