fix: allow invalid certs

This commit is contained in:
2025-03-08 18:31:44 +00:00
parent 8c3756e3e8
commit 9606b91e6d
3 changed files with 7 additions and 4 deletions

View File

@ -14,7 +14,7 @@ pub struct Cloudflare {
impl Cloudflare { impl Cloudflare {
pub fn new(token: &str, reverse_zone_id: &str, forward_zone_id: &str) -> Cloudflare { pub fn new(token: &str, reverse_zone_id: &str, forward_zone_id: &str) -> Cloudflare {
Self { Self {
api: JsonApi::token("https://api.cloudflare.com", &format!("Bearer {}", token)) api: JsonApi::token("https://api.cloudflare.com", &format!("Bearer {}", token), false)
.unwrap(), .unwrap(),
reverse_zone_id: reverse_zone_id.to_owned(), reverse_zone_id: reverse_zone_id.to_owned(),
forward_zone_id: forward_zone_id.to_owned(), forward_zone_id: forward_zone_id.to_owned(),

View File

@ -11,11 +11,14 @@ pub struct JsonApi {
} }
impl JsonApi { impl JsonApi {
pub fn token(base: &str, token: &str) -> anyhow::Result<Self> { pub fn token(base: &str, token: &str, allow_invalid_certs: bool) -> anyhow::Result<Self> {
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
headers.insert(AUTHORIZATION, token.parse()?); headers.insert(AUTHORIZATION, token.parse()?);
let client = Client::builder().default_headers(headers).build()?; let client = Client::builder()
.danger_accept_invalid_certs(allow_invalid_certs)
.default_headers(headers)
.build()?;
Ok(Self { Ok(Self {
client, client,
base: base.parse()?, base: base.parse()?,

View File

@ -19,7 +19,7 @@ impl MikrotikRouter {
STANDARD.encode(format!("{}:{}", username, password)) STANDARD.encode(format!("{}:{}", username, password))
); );
Self { Self {
api: JsonApi::token(url, &auth).unwrap(), api: JsonApi::token(url, &auth, true).unwrap(),
} }
} }
} }