Skip to content

Commit

Permalink
Merge pull request #35 from siudej/master
Browse files Browse the repository at this point in the history
Allow unverified certificates
  • Loading branch information
nooberfsh authored Nov 14, 2023
2 parents dd860d7 + bb0ee0a commit ff540ce
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct ClientBuilder {
auth: Option<Auth>,
max_attempt: usize,
ssl: Option<Ssl>,
no_verify: bool,
}

#[derive(Debug)]
Expand All @@ -54,6 +55,7 @@ impl ClientBuilder {
auth: None,
max_attempt: 3,
ssl: None,
no_verify: false,
}
}

Expand All @@ -67,6 +69,11 @@ impl ClientBuilder {
self
}

pub fn no_verify(mut self, nv: bool) -> Self {
self.no_verify = nv;
self
}

pub fn source(mut self, s: impl ToString) -> Self {
self.session.source = s.to_string();
self
Expand Down Expand Up @@ -196,6 +203,10 @@ impl ClientBuilder {
let mut client_builder =
reqwest::ClientBuilder::new().timeout(session.client_request_timeout);

if self.no_verify {
client_builder = client_builder.danger_accept_invalid_certs(true);
}

if let Some(ssl) = &self.ssl {
if let Some(root) = &ssl.root_cert {
client_builder = client_builder.add_root_certificate(root.0.clone());
Expand Down

0 comments on commit ff540ce

Please sign in to comment.