mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-14 13:49:40 -06:00
15 lines
484 B
JavaScript
Executable File
15 lines
484 B
JavaScript
Executable File
import { createServerError } from "../utils/errorUtils.js";
|
|
|
|
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");
|
|
}
|
|
return cert;
|
|
};
|
|
|
|
export { fetchMonitorCertificate };
|