MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getSSLInfo

Function getSSLInfo

apps/api/src/controllers/tools.controller.ts:199–236  ·  view source on GitHub ↗
(
  hostname: string,
)

Source from the content-addressed store, hash-verified

197}
198
199async function getSSLInfo(
200 hostname: string,
201): Promise<SiteCheckResult['technical']['ssl'] | null> {
202 return new Promise((resolve) => {
203 const socket = tls.connect(
204 {
205 host: hostname,
206 port: 443,
207 servername: hostname,
208 rejectUnauthorized: false,
209 },
210 () => {
211 const cert = socket.getPeerCertificate(true);
212 socket.destroy();
213
214 if (!cert || !cert.valid_to) {
215 resolve(null);
216 return;
217 }
218
219 resolve({
220 valid: new Date(cert.valid_to) > new Date(),
221 issuer: cert.issuer?.CN || 'Unknown',
222 expires: cert.valid_to,
223 });
224 },
225 );
226
227 socket.on('error', () => {
228 resolve(null);
229 });
230
231 setTimeout(() => {
232 socket.destroy();
233 resolve(null);
234 }, 3000);
235 });
236}
237
238async function resolveHostname(hostname: string): Promise<string> {
239 try {

Callers 1

siteCheckerFunction · 0.85

Calls 1

destroyMethod · 0.45

Tested by

no test coverage detected