feat: add support for self-signed certificates and update changelog, fixes #351

This commit is contained in:
Raj Nandan Sharma
2025-03-23 12:32:36 +05:30
parent d30d99d8c2
commit 93339ce9df
5 changed files with 24 additions and 4 deletions

View File

@@ -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

View File

@@ -78,7 +78,7 @@
<div class="col-span-12">
<Accordion.Root bind:value={index} class="accor">
<Accordion.Item value={accordionValue}>
<Accordion.Trigger class="px-4 hover:bg-muted hover:no-underline">
<Accordion.Trigger class="rounded-md px-4 hover:bg-muted hover:no-underline">
<div class="w-full text-left hover:no-underline">
<p class="flex gap-x-2 text-xs font-semibold">
{#if incidentType == "INCIDENT"}

View File

@@ -722,6 +722,18 @@
></textarea>
</div>
{/if}
<div class="col-span-6">
<label class="cursor-pointer">
<input
type="checkbox"
on:change={(e) => {
newMonitor.apiConfig.allowSelfSignedCert = e.target.checked;
}}
checked={newMonitor.apiConfig.allowSelfSignedCert}
/>
<span class="ml-2 text-sm">Allow Self Signed Certificate</span>
</label>
</div>
<div class="col-span-6">
<Label for="eval">Eval</Label>
<p class="my-1 text-xs text-muted-foreground">

View File

@@ -73,7 +73,8 @@
body: "",
timeout: 10000,
eval: DefaultAPIEval,
hideURLForGet: "NO"
hideURLForGet: "NO",
allowSelfSignedCert: false
},
tcpConfig: {
hosts: [], //{timeout: 1000, host: "", type:""}

View File

@@ -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;
}