diff --git a/server/model/monitor.js b/server/model/monitor.js index 4cbb56e1a..2cb309e08 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -131,6 +131,9 @@ class Monitor extends BeanModel { mqttPassword: this.mqttPassword, authWorkstation: this.authWorkstation, authDomain: this.authDomain, + tlsCa: this.tlsCa, + tlsCert: this.tlsCert, + tlsKey: this.tlsKey, }; } @@ -308,6 +311,18 @@ class Monitor extends BeanModel { options.httpsAgent = new https.Agent(httpsAgentOptions); } + if (this.auth_method === "mtls") { + if (this.tlsCert !== null && this.tlsCert !== "") { + options.httpsAgent.options.cert = Buffer.from(this.tlsCert); + } + if (this.tlsCa !== null && this.tlsCa !== "") { + options.httpsAgent.options.ca = Buffer.from(this.tlsCa); + } + if (this.tlsKey !== null && this.tlsKey !== "") { + options.httpsAgent.options.key = Buffer.from(this.tlsKey); + } + } + log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`); log.debug("monitor", `[${this.name}] Axios Request`); @@ -813,7 +828,6 @@ class Monitor extends BeanModel { domain: this.authDomain, workstation: this.authWorkstation ? this.authWorkstation : undefined }); - } else { res = await axios.request(options); } diff --git a/server/server.js b/server/server.js index 1073f3bef..91b0a9444 100644 --- a/server/server.js +++ b/server/server.js @@ -688,6 +688,9 @@ let needSetup = false; bean.headers = monitor.headers; bean.basic_auth_user = monitor.basic_auth_user; bean.basic_auth_pass = monitor.basic_auth_pass; + bean.tlsCa = monitor.tlsCa; + bean.tlsCert = monitor.tlsCert; + bean.tlsKey = monitor.tlsKey; bean.interval = monitor.interval; bean.retryInterval = monitor.retryInterval; bean.resendInterval = monitor.resendInterval; diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index e9cbd8245..6d7353fee 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -531,28 +531,47 @@ NTLM + + mTLS + - - {{ $t("Username") }} - - - - - {{ $t("Password") }} - - - + - {{ $t("Domain") }} - + {{ $t("Cert") }} + + + + {{ $t("Key") }} + + + + {{ $t("CA") }} + + + + + + {{ $t("Username") }} + - {{ $t("Workstation") }} - + {{ $t("Password") }} + + + + {{ $t("Domain") }} + + + + + {{ $t("Workstation") }} + + +