From b660f64b916d24a746af465235a45119f66ebb6f Mon Sep 17 00:00:00 2001 From: HdroguettA Date: Thu, 12 Oct 2023 09:48:47 +1100 Subject: [PATCH] Ignore TLS/SSL error for Redis --- server/model/monitor.js | 2 +- server/util-server.js | 10 +++++++--- src/lang/en.json | 1 + src/pages/EditMonitor.vue | 20 ++++++++++++++++---- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 3e595f92..980fd304 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -815,7 +815,7 @@ class Monitor extends BeanModel { } else if (this.type === "redis") { let startTime = dayjs().valueOf(); - bean.msg = await redisPingAsync(this.databaseConnectionString); + bean.msg = await redisPingAsync(this.databaseConnectionString, !this.ignoreTls); bean.status = UP; bean.ping = dayjs().valueOf() - startTime; diff --git a/server/util-server.js b/server/util-server.js index 5f47561c..fa635d65 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -559,12 +559,16 @@ exports.radius = function ( /** * Redis server ping * @param {string} dsn The redis connection string - * @returns {Promise} Response from redis server + * @param {boolean} rejectUnauthorized If false, allows unverified server certificates. + * @returns {Promise} */ -exports.redisPingAsync = function (dsn) { +exports.redisPingAsync = function (dsn, rejectUnauthorized) { return new Promise((resolve, reject) => { const client = redis.createClient({ - url: dsn + url: dsn, + socket: { + rejectUnauthorized + } }); client.on("error", (err) => { if (client.isOpen) { diff --git a/src/lang/en.json b/src/lang/en.json index f5ebea2a..c1649a07 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -76,6 +76,7 @@ "resendDisabled": "Resend disabled", "retriesDescription": "Maximum retries before the service is marked as down and a notification is sent", "ignoreTLSError": "Ignore TLS/SSL error for HTTPS websites", + "ignoreTLSErrorGeneral": "Ignore TLS/SSL error for connection", "upsideDownModeDescription": "Flip the status upside down. If the service is reachable, it is DOWN.", "maxRedirectDescription": "Maximum number of redirects to follow. Set to 0 to disable redirects.", "Upside Down Mode": "Upside Down Mode", diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index cab85fe9..dc25d2d9 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -429,10 +429,10 @@ -
+
@@ -1113,9 +1113,21 @@ message HealthCheckResponse { } return list; - }, + }, - }, + /** + * Retrieves the appropriate ignore TLS error label based on the monitor type. + * + * @return {string} Returns the non specific label if the monitor type is 'redis', + * otherwise, returns the default. + */ + ignoreTlsLabel() { + return this.monitor.type === "redis" + ? this.$t("ignoreTLSErrorGeneral") + : this.$t("ignoreTLSError"); + } + }, + watch: { "$root.proxyList"() { if (this.isAdd) {