fix: option to ignore certificate errors #76
This commit is contained in:
+3
-2
@@ -49,8 +49,9 @@ const init = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Connection settings
|
// Connection settings
|
||||||
const options = user === null || password === null ? null : { username: user, password: password };
|
const masked = password === null ? null : "*".repeat(password.length);
|
||||||
const masked = password === null ? "null" : "*".repeat(password.length);
|
const options = user === null || password === null ? {} : { username: user, password: password };
|
||||||
|
options.rejectUnauthorized = !("ignore_certificate_errors" in ARGS);
|
||||||
console.log("MQTT Connecting:", `${user}:${masked}@${url.toString()}`);
|
console.log("MQTT Connecting:", `${user}:${masked}@${url.toString()}`);
|
||||||
INTEGRATION.client = mqtt.connect(url.toString(), options);
|
INTEGRATION.client = mqtt.connect(url.toString(), options);
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -1,5 +1,6 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
const https = require("https");
|
||||||
const hardware = require("./hardware");
|
const hardware = require("./hardware");
|
||||||
const integration = require("./integration");
|
const integration = require("./integration");
|
||||||
const { app, nativeTheme, globalShortcut, ipcMain, session, BaseWindow, WebContentsView } = require("electron");
|
const { app, nativeTheme, globalShortcut, ipcMain, session, BaseWindow, WebContentsView } = require("electron");
|
||||||
@@ -845,7 +846,8 @@ const onlineStatus = (url, interval = 1000, timeout = 60000) => {
|
|||||||
const elapsed = Date.now() - start;
|
const elapsed = Date.now() - start;
|
||||||
try {
|
try {
|
||||||
if (!url.startsWith("data:")) {
|
if (!url.startsWith("data:")) {
|
||||||
await axios.get(url, { timeout: 10000 });
|
const agent = new https.Agent({ rejectUnauthorized: !("ignore_certificate_errors" in ARGS) });
|
||||||
|
await axios.get(url, { httpsAgent: agent, timeout: 10000 });
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -853,6 +855,9 @@ const onlineStatus = (url, interval = 1000, timeout = 60000) => {
|
|||||||
console.warn(`Checking Connection: ${url}`, error.message);
|
console.warn(`Checking Connection: ${url}`, error.message);
|
||||||
}
|
}
|
||||||
if (elapsed >= timeout) {
|
if (elapsed >= timeout) {
|
||||||
|
if (error.message?.includes("certificate")) {
|
||||||
|
console.error("Certificate Error: See https://github.com/leukipp/touchkio/issues/76");
|
||||||
|
}
|
||||||
resolve(false);
|
resolve(false);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(check, interval);
|
setTimeout(check, interval);
|
||||||
|
|||||||
Reference in New Issue
Block a user