UNPKG

ssl-checker

Version:

Zero-dependency SSL/TLS certificate checker for Node.js — HTTPS, SMTP, IMAP, POP3, FTP via STARTTLS

61 lines (60 loc) 1.63 kB
import * as https from "https"; interface ICertIssuerSubject { CN: string; O?: string; C?: string; } interface IChainCertificate { subject: ICertIssuerSubject; issuer: ICertIssuerSubject; validFrom: string; validTo: string; fingerprint256: string; serialNumber: string; } interface IHsts { enabled: boolean; maxAge?: number; includeSubDomains?: boolean; preload?: boolean; } type Grade = "A+" | "A" | "B" | "C" | "D" | "F"; interface IGrade { grade: Grade; protocols: string[]; weakCiphers: boolean; reasons: string[]; } interface IResolvedValues { valid: boolean; validationError: string | null; validFrom: string; validTo: string; daysRemaining: number; expiringSoon?: boolean; validFor?: string[]; issuer: ICertIssuerSubject; subject: ICertIssuerSubject; fingerprint256: string; serialNumber: string; protocol: string; cipher: string; bits: number; chain: IChainCertificate[]; chainComplete: boolean; hsts: IHsts | null; grade?: IGrade; } type Protocol = "https" | "smtp" | "imap" | "pop3" | "ftp"; type Options = https.RequestOptions & { validateSubjectAltName?: boolean; timeout?: number; warnDays?: number; protocol?: Protocol; servername?: string; grade?: boolean; }; declare const sslChecker: (host: string, options?: Partial<Options>) => Promise<IResolvedValues>; declare const sslCheckerBatch: (hosts: string[], options?: Partial<Options>) => Promise<Map<string, IResolvedValues | Error>>; export { sslChecker, sslCheckerBatch }; export default sslChecker;