From 93339ce9df1338bf0570a8568ddb8c69eb001fcf Mon Sep 17 00:00:00 2001 From: Raj Nandan Sharma Date: Sun, 23 Mar 2025 12:32:36 +0530 Subject: [PATCH] feat: add support for self-signed certificates and update changelog, fixes #351 --- docs/changelogs.md | 1 + src/lib/components/IncidentNew.svelte | 2 +- src/lib/components/manage/monitorSheet.svelte | 12 ++++++++++++ src/lib/components/manage/monitorsAdd.svelte | 3 ++- src/lib/server/services/apiCall.js | 10 ++++++++-- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/changelogs.md b/docs/changelogs.md index 6aa5f41..9bed0a8 100644 --- a/docs/changelogs.md +++ b/docs/changelogs.md @@ -98,6 +98,7 @@ Here are the changelogs for Kener. Changelogs are only published when there are - The event that has been edited isn't clickable after you save it [#350](https://github.com/rajnandan1/kener/issues/350) - /app/package.json ERROR on fresh install [#346](https://github.com/rajnandan1/kener/issues/346) - Site stops when monitor processing throws an error [#345](https://github.com/rajnandan1/kener/issues/345) + - Support for Self Signed Certificates [#351](https://github.com/rajnandan1/kener/issues/351) ### Migration Notes diff --git a/src/lib/components/IncidentNew.svelte b/src/lib/components/IncidentNew.svelte index 16ca5d5..c7864be 100644 --- a/src/lib/components/IncidentNew.svelte +++ b/src/lib/components/IncidentNew.svelte @@ -78,7 +78,7 @@
- +

{#if incidentType == "INCIDENT"} diff --git a/src/lib/components/manage/monitorSheet.svelte b/src/lib/components/manage/monitorSheet.svelte index 5068e4b..a71e73b 100644 --- a/src/lib/components/manage/monitorSheet.svelte +++ b/src/lib/components/manage/monitorSheet.svelte @@ -722,6 +722,18 @@ >

{/if} +
+ +

diff --git a/src/lib/components/manage/monitorsAdd.svelte b/src/lib/components/manage/monitorsAdd.svelte index 2f10f3a..c82a4ad 100644 --- a/src/lib/components/manage/monitorsAdd.svelte +++ b/src/lib/components/manage/monitorsAdd.svelte @@ -73,7 +73,8 @@ body: "", timeout: 10000, eval: DefaultAPIEval, - hideURLForGet: "NO" + hideURLForGet: "NO", + allowSelfSignedCert: false }, tcpConfig: { hosts: [], //{timeout: 1000, host: "", type:""} diff --git a/src/lib/server/services/apiCall.js b/src/lib/server/services/apiCall.js index f4812a3..2f54ecf 100644 --- a/src/lib/server/services/apiCall.js +++ b/src/lib/server/services/apiCall.js @@ -4,6 +4,8 @@ import { GetRequiredSecrets, ReplaceAllOccurrences } from "../tool.js"; import { UP, DOWN, DEGRADED, REALTIME, TIMEOUT, ERROR, MANUAL } from "../constants.js"; import * as cheerio from "cheerio"; import { DefaultAPIEval } from "../../anywhere.js"; +import version from "../../version.js"; +import https from "https"; class ApiCall { monitor; @@ -18,7 +20,7 @@ class ApiCall { async execute() { let axiosHeaders = {}; - axiosHeaders["User-Agent"] = "Kener/" + "3.1.0"; + axiosHeaders["User-Agent"] = `Kener/${version()}`; axiosHeaders["Accept"] = "*/*"; let body = this.monitor.type_data.body; @@ -31,7 +33,7 @@ class ApiCall { } let method = this.monitor.type_data.method; - let timeout = this.monitor.type_data.timeout || 5000; + let timeout = this.monitor.type_data.timeout || 10000; let tag = this.monitor.tag; let monitorEval = !!this.monitor.type_data.eval ? this.monitor.type_data.eval : DefaultAPIEval; @@ -69,6 +71,10 @@ class ApiCall { transformResponse: (r) => r, }; + if (!!this.monitor.type_data.allowSelfSignedCert) { + options.httpsAgent = new https.Agent({ rejectUnauthorized: false }); + } + if (!!body) { options.data = body; }