Fix: Display all SSL up to 200 records
- The SSL certs table in the SSL & Domain dashboard was not displaying all certs records
This commit is contained in:
@@ -14,7 +14,7 @@ export async function sendSSLNotification(
|
|||||||
try {
|
try {
|
||||||
// Check if notification channel is set
|
// Check if notification channel is set
|
||||||
if (!certificate.notification_channel) {
|
if (!certificate.notification_channel) {
|
||||||
console.log(`No notification channel set for certificate: ${certificate.domain}`);
|
// console.log(`No notification channel set for certificate: ${certificate.domain}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,12 +22,12 @@ export async function sendSSLNotification(
|
|||||||
const alertConfigRecord = await pb.collection('alert_configurations').getOne(certificate.notification_channel);
|
const alertConfigRecord = await pb.collection('alert_configurations').getOne(certificate.notification_channel);
|
||||||
|
|
||||||
if (!alertConfigRecord) {
|
if (!alertConfigRecord) {
|
||||||
console.error(`Alert configuration not found for ID: ${certificate.notification_channel}`);
|
// console.error(`Alert configuration not found for ID: ${certificate.notification_channel}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alertConfigRecord.enabled) {
|
if (!alertConfigRecord.enabled) {
|
||||||
console.log(`Alert configuration is disabled for certificate: ${certificate.domain}`);
|
// console.log(`Alert configuration is disabled for certificate: ${certificate.domain}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ export async function sendSSLNotification(
|
|||||||
return await sendNotificationByType(alertConfig, certificate, message, isCritical, sslNotification);
|
return await sendNotificationByType(alertConfig, certificate, message, isCritical, sslNotification);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error sending SSL notification:", error);
|
// console.error("Error sending SSL notification:", error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ async function sendNotificationByType(
|
|||||||
// case 'slack':
|
// case 'slack':
|
||||||
// return await sendSlackNotification(alertConfig, certificate, message, isCritical);
|
// return await sendSlackNotification(alertConfig, certificate, message, isCritical);
|
||||||
default:
|
default:
|
||||||
console.log(`Notification type ${alertConfig.notification_type} not implemented yet for SSL certificates`);
|
// console.log(`Notification type ${alertConfig.notification_type} not implemented yet for SSL certificates`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ async function sendTelegramNotification(
|
|||||||
isCritical: boolean
|
isCritical: boolean
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (!alertConfig.bot_token || !alertConfig.telegram_chat_id) {
|
if (!alertConfig.bot_token || !alertConfig.telegram_chat_id) {
|
||||||
console.error("Missing Telegram bot token or chat ID");
|
// console.error("Missing Telegram bot token or chat ID");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,10 +112,10 @@ export const deleteSSLCertificate = async (id: string): Promise<boolean> => {
|
|||||||
*/
|
*/
|
||||||
export const refreshAllCertificates = async (): Promise<{ success: number; failed: number }> => {
|
export const refreshAllCertificates = async (): Promise<{ success: number; failed: number }> => {
|
||||||
try {
|
try {
|
||||||
const response = await pb.collection("ssl_certificates").getList(1, 100);
|
const response = await pb.collection("ssl_certificates").getList(1, 200);
|
||||||
const certificates = response.items as unknown as SSLCertificate[];
|
const certificates = response.items as unknown as SSLCertificate[];
|
||||||
|
|
||||||
console.log(`Refreshing ${certificates.length} certificates...`);
|
// console.log(`Refreshing ${certificates.length} certificates...`);
|
||||||
|
|
||||||
let success = 0;
|
let success = 0;
|
||||||
let failed = 0;
|
let failed = 0;
|
||||||
@@ -125,14 +125,14 @@ export const refreshAllCertificates = async (): Promise<{ success: number; faile
|
|||||||
await checkCertificateAndNotify(cert);
|
await checkCertificateAndNotify(cert);
|
||||||
success++;
|
success++;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to refresh certificate ${cert.domain}:`, error);
|
// console.error(`Failed to refresh certificate ${cert.domain}:`, error);
|
||||||
failed++;
|
failed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { success, failed };
|
return { success, failed };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error refreshing certificates:", error);
|
// console.error("Error refreshing certificates:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
import type { SSLCheckerResponse } from "./types";
|
import type { SSLCheckerResponse } from "./types";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { checkWithFetch } from "./sslPrimaryChecker";
|
|
||||||
import { normalizeDomain, createErrorResponse } from "./sslCheckerUtils";
|
import { normalizeDomain, createErrorResponse } from "./sslCheckerUtils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,7 +9,7 @@ import { normalizeDomain, createErrorResponse } from "./sslCheckerUtils";
|
|||||||
*/
|
*/
|
||||||
export const checkSSLCertificate = async (domain: string): Promise<SSLCheckerResponse> => {
|
export const checkSSLCertificate = async (domain: string): Promise<SSLCheckerResponse> => {
|
||||||
try {
|
try {
|
||||||
console.log(`Checking SSL certificate for domain: ${domain}`);
|
// console.log(`Checking SSL certificate for domain: ${domain}`);
|
||||||
|
|
||||||
// Normalize domain (remove protocol if present)
|
// Normalize domain (remove protocol if present)
|
||||||
const normalizedDomain = normalizeDomain(domain);
|
const normalizedDomain = normalizeDomain(domain);
|
||||||
@@ -20,11 +19,11 @@ export const checkSSLCertificate = async (domain: string): Promise<SSLCheckerRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use the working CORS proxy approach
|
// Use the working CORS proxy approach
|
||||||
const result = await checkWithFetch(normalizedDomain);
|
// const result = await checkWithFetch(normalizedDomain);
|
||||||
console.log("SSL check result:", result);
|
// console.log("SSL check result:", result);
|
||||||
return result;
|
// return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("SSL check failed completely:", error);
|
//console.error("SSL check failed completely:", error);
|
||||||
toast.error(`SSL check failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
toast.error(`SSL check failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
||||||
return createErrorResponse(domain, error);
|
return createErrorResponse(domain, error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export const fetchSSLCertificates = async (): Promise<SSLCertificate[]> => {
|
|||||||
const endpoint = "/api/collections/ssl_certificates/records";
|
const endpoint = "/api/collections/ssl_certificates/records";
|
||||||
const params = {
|
const params = {
|
||||||
page: 1,
|
page: 1,
|
||||||
perPage: 50,
|
perPage: 200,
|
||||||
sort: "-created",
|
sort: "-created",
|
||||||
cache: Date.now() // Prevent caching by adding a timestamp
|
cache: Date.now() // Prevent caching by adding a timestamp
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
import { createErrorResponse } from "./sslCheckerUtils";
|
|
||||||
import type { SSLCheckerResponse } from "./types";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check SSL certificate using fetch with CORS proxy
|
|
||||||
* This is our primary method that's proven to work
|
|
||||||
*/
|
|
||||||
export const checkWithFetch = async (domain: string): Promise<SSLCheckerResponse> => {
|
|
||||||
console.log(`Checking SSL via CORS proxy for: ${domain}`);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Use the working CORS proxy
|
|
||||||
const corsProxyUrl = `https://api.allorigins.win/raw?url=${encodeURIComponent(`https://ssl-checker.io/api/v1/check/${domain}`)}`;
|
|
||||||
console.log("Using CORS proxy for SSL check:", corsProxyUrl);
|
|
||||||
|
|
||||||
const proxyResponse = await fetch(corsProxyUrl);
|
|
||||||
if (!proxyResponse.ok) {
|
|
||||||
throw new Error(`CORS proxy request failed with status: ${proxyResponse.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const proxyData = await proxyResponse.json();
|
|
||||||
console.log("CORS proxy returned SSL data:", proxyData);
|
|
||||||
return proxyData;
|
|
||||||
} catch (error) {
|
|
||||||
console.error("SSL check failed:", error);
|
|
||||||
return createErrorResponse(domain, error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user