Merge 2e2acbd48a
into 10a518e72e
This commit is contained in:
commit
af2078423d
|
@ -24,6 +24,7 @@ const { CookieJar } = require("tough-cookie");
|
|||
const { HttpsCookieAgent } = require("http-cookie-agent/http");
|
||||
const https = require("https");
|
||||
const http = require("http");
|
||||
const tls = require("tls");
|
||||
|
||||
const rootCertificates = rootCertificatesFingerprints();
|
||||
|
||||
|
@ -613,6 +614,45 @@ class Monitor extends BeanModel {
|
|||
|
||||
} else if (this.type === "port") {
|
||||
bean.ping = await tcping(this.hostname, this.port);
|
||||
if (this.isEnabledExpiryNotification()) {
|
||||
const host = this.hostname;
|
||||
const port = this.port || 443;
|
||||
try {
|
||||
const options = {
|
||||
host,
|
||||
port,
|
||||
servername: host,
|
||||
};
|
||||
|
||||
// Convert TLS connect to a Promise and await it
|
||||
const tlsInfoObject = await new Promise((resolve, reject) => {
|
||||
const socket = tls.connect(options);
|
||||
|
||||
socket.on("secureConnect", () => {
|
||||
try {
|
||||
const info = checkCertificate(socket);
|
||||
socket.end();
|
||||
resolve(info);
|
||||
} catch (error) {
|
||||
socket.end();
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("error", (error) => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
socket.setTimeout(10000, () => {
|
||||
socket.end();
|
||||
reject(new Error("Connection timed out"));
|
||||
});
|
||||
});
|
||||
await this.handleTlsInfo(tlsInfoObject);
|
||||
} catch (error) {
|
||||
console.log("Retrieve certificate failed");
|
||||
}
|
||||
}
|
||||
bean.msg = "";
|
||||
bean.status = UP;
|
||||
|
||||
|
|
|
@ -612,7 +612,7 @@
|
|||
|
||||
<h2 v-if="monitor.type !== 'push'" class="mt-5 mb-2">{{ $t("Advanced") }}</h2>
|
||||
|
||||
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' " class="my-3 form-check" :title="monitor.ignoreTls ? $t('ignoredTLSError') : ''">
|
||||
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' || monitor.type === 'json-query' || monitor.type === 'port' " class="my-3 form-check" :title="monitor.ignoreTls ? $t('ignoredTLSError') : ''">
|
||||
<input id="expiry-notification" v-model="monitor.expiryNotification" class="form-check-input" type="checkbox" :disabled="monitor.ignoreTls">
|
||||
<label class="form-check-label" for="expiry-notification">
|
||||
{{ $t("Certificate Expiry Notification") }}
|
||||
|
|
Loading…
Reference in New Issue