Files
Checkmate/server/controllers/controllerUtils.js
T

14 lines
484 B
JavaScript
Raw Normal View History

import { createServerError } from "../utils/errorUtils.js";
2025-04-20 11:29:53 -07:00
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 createServerError("Certificate not found");
2025-04-20 11:29:53 -07:00
}
return cert;
};
export { fetchMonitorCertificate };