diff --git a/Server/controllers/controllerUtils.js b/Server/controllers/controllerUtils.js index 38c45b3cb..bee091db8 100644 --- a/Server/controllers/controllerUtils.js +++ b/Server/controllers/controllerUtils.js @@ -17,6 +17,10 @@ const fetchMonitorCertificate = async (sslChecker, monitor) => { const monitorUrl = new URL(monitor.url); const hostname = monitorUrl.hostname; const cert = await sslChecker(hostname); + // Throw an error if no cert or if cert.validTo is not present + if (cert?.validTo === null || cert?.validTo === undefined) { + throw new Error("Certificate not found"); + } return cert; } catch (error) { throw error;