diff --git a/server/model/monitor.js b/server/model/monitor.js index 5dcb7171c..13d901af4 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -22,6 +22,7 @@ const Gamedig = require("gamedig"); const jsonata = require("jsonata"); const jwt = require("jsonwebtoken"); const { UptimeCalculator } = require("../uptime-calculator"); +const { X509Certificate } = require("node:crypto"); /** * status: @@ -507,6 +508,12 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] Check cert`); try { let tlsInfoObject = checkCertificate(res); + + // Check if the certificate obtained matches the hostname set for the monitor (if redirected) + let certObject = new X509Certificate(tlsInfoObject.certInfo.raw); + let hostnameMatch = certObject.checkHost(this.getUrl()?.hostname) !== undefined; + tlsInfoObject.hostnameMatchMonitorUrl = hostnameMatch; + tlsInfo = await this.updateTlsInfo(tlsInfoObject); if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) { diff --git a/src/icon.js b/src/icon.js index 7bdfe1ca0..25fd73bc0 100644 --- a/src/icon.js +++ b/src/icon.js @@ -10,6 +10,7 @@ import { faArrowAltCircleUp, faCog, faEdit, + faExclamationTriangle, faEye, faEyeSlash, faList, @@ -56,6 +57,7 @@ library.add( faArrowAltCircleUp, faCog, faEdit, + faExclamationTriangle, faEye, faEyeSlash, faList, diff --git a/src/lang/en.json b/src/lang/en.json index 057b2790b..c9eb7cb6a 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -380,6 +380,7 @@ "Query": "Query", "settingsCertificateExpiry": "TLS Certificate Expiry", "certificationExpiryDescription": "HTTPS Monitors trigger notification when TLS certificate expires in:", + "certHostnameMismatch": "Certificate hostname is not valid for this monitor url.", "Setup Docker Host": "Setup Docker Host", "Connection Type": "Connection Type", "Docker Daemon": "Docker Daemon", diff --git a/src/pages/Details.vue b/src/pages/Details.vue index 20c8aa13a..9221db416 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -156,6 +156,7 @@

()

{{ tlsInfo.certInfo.daysRemaining }} {{ $tc("day", tlsInfo.certInfo.daysRemaining) }} + @@ -791,4 +792,13 @@ table { margin-left: 0 !important; } +.cert-info-warn { + margin-left: 4px; + opacity: 0.5; + + .dark & { + opacity: 0.7; + } +} +