From daca38a554b60431bf36716b6cf99c80ce36a28e Mon Sep 17 00:00:00 2001 From: HdroguettA Date: Mon, 20 May 2024 07:34:01 +1000 Subject: [PATCH] Ignore TLS/SSL error for Redis (#3878) Co-authored-by: Frank Elsinga --- server/model/monitor.js | 2 +- server/util-server.js | 10 +++++++--- src/lang/en.json | 1 + src/pages/EditMonitor.vue | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 69b685c77..1b11c614e 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -852,7 +852,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 d728b6c20..f425ac7f4 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -486,12 +486,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} Response from server */ -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 d5cdec060..d37527068 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -80,6 +80,7 @@ "resendDisabled": "Resend disabled", "retriesDescription": "Maximum retries before the service is marked as down and a notification is sent", "ignoreTLSError": "Ignore TLS/SSL errors 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 38017778a..0533eb0fe 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -508,10 +508,10 @@ -
+