|
|
|
@ -512,10 +512,22 @@ class Monitor extends BeanModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let tlsInfo;
|
|
|
|
|
// Store tlsInfo when key material is received
|
|
|
|
|
options.httpsAgent.on("keylog", (line, tlsSocket) => {
|
|
|
|
|
let tlsInfo = {};
|
|
|
|
|
// Store tlsInfo when secureConnect event is emitted
|
|
|
|
|
// The keylog event listener is a workaround to access the tlsSocket
|
|
|
|
|
options.httpsAgent.once("keylog", async (line, tlsSocket) => {
|
|
|
|
|
tlsSocket.once('secureConnect', async () => {
|
|
|
|
|
tlsInfo = checkCertificate(tlsSocket);
|
|
|
|
|
|
|
|
|
|
tlsInfo.valid = tlsSocket.authorized || false;
|
|
|
|
|
await this.updateTlsInfo(tlsInfo);
|
|
|
|
|
this.prometheus?.update(null, tlsInfo);
|
|
|
|
|
|
|
|
|
|
if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) {
|
|
|
|
|
log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`);
|
|
|
|
|
await this.checkCertExpiryNotifications(tlsInfo);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
log.debug("monitor", `[${this.name}] Axios Options: ${JSON.stringify(options)}`);
|
|
|
|
@ -527,22 +539,6 @@ class Monitor extends BeanModel {
|
|
|
|
|
bean.msg = `${res.status} - ${res.statusText}`;
|
|
|
|
|
bean.ping = dayjs().valueOf() - startTime;
|
|
|
|
|
|
|
|
|
|
// Store certificate and check for expiry if https is used
|
|
|
|
|
if (this.getUrl()?.protocol === "https:") {
|
|
|
|
|
// No way to listen for the `secureConnection` event, so we do it here
|
|
|
|
|
const tlssocket = res.request.res.socket;
|
|
|
|
|
|
|
|
|
|
if (tlssocket) {
|
|
|
|
|
tlsInfo.valid = tlssocket.authorized || false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await this.updateTlsInfo(tlsInfo);
|
|
|
|
|
if (!this.getIgnoreTls() && this.isEnabledExpiryNotification()) {
|
|
|
|
|
log.debug("monitor", `[${this.name}] call checkCertExpiryNotifications`);
|
|
|
|
|
await this.checkCertExpiryNotifications(tlsInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.env.UPTIME_KUMA_LOG_RESPONSE_BODY_MONITOR_ID === this.id) {
|
|
|
|
|
log.info("monitor", res.data);
|
|
|
|
|
}
|
|
|
|
|