Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mohameedsherif committed May 23, 2024
1 parent 3363f1d commit b09543d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ const getCANotAfter = (notBefore: any) => {
// Function to check if a certificate file has expired
export const isCertificateExpired = async (certFilePath: string): Promise<boolean> => {
return new Promise((resolve, reject) => {

try {
// Check if the file exists
if (!fs.existsSync(certFilePath)) {
reject('Certificate not found')
}
// Check if the file exists
if (!fs.existsSync(certFilePath)) {
reject('Certificate not found')
}

// Read the certificate file
const certData = fs.readFileSync(certFilePath, 'utf8')



// check if cert exists
if (!certData) {
reject('Certificate not found')
Expand All @@ -77,7 +74,6 @@ export const isCertificateExpired = async (certFilePath: string): Promise<boolea
const isExpired = expiryDate < new Date()

resolve(isExpired)

} catch (error) {
// Handle errors
console.error(`Error checking certificate expiry: ${error}`)
Expand All @@ -91,9 +87,7 @@ export const isDomainExists = async (domainToCheck: string, certificatePath: str
// Read the certificate file
const certificateContents = fs.readFileSync(certificatePath, 'utf8')


if(!certificateContents) {

if (!certificateContents) {
throw new Error('Certificate not found')
}

Expand Down

0 comments on commit b09543d

Please sign in to comment.