Build Node.JS Domain SSL Certificate Expiry Date Checker & Validator in Express Using Javascript

You are currently viewing Build Node.JS Domain SSL Certificate Expiry Date Checker & Validator in Express Using Javascript

Build Node.js Domain SSL Certificate Expiry Date Checker & Validator in Express Using Javascript

import sslChecker from "ssl-checker";
import express from 'express'
 
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: false }));
 
 
 
app.set('view engine', 'ejs')
 
app.get('/', (req, res) => {
    res.render('index',{data:''})
})
 
app.post('/getsslinfo', (req, res) => {
    let domain = req.body.domain
    console.log(domain)
 
    getSslDetails(domain)
        .then((response) => {
            console.log(response)
 
            res.render('index',{data:response})
        })
})
 
 
const getSslDetails = async (hostname) =>
    await sslChecker(hostname);
 
app.listen(5000, () => {
    console.log("App is listening on port 5000")
})

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="/getsslinfo" method="post">
        <input type="text" name="domain" id="" placeholder="Enter the domain" required>
        <input type="submit" value="Get Info">
    </form>
    <%if(data){%>
    <table>
        <thead>
            <tr>
                <th>Days Remaining</th>
                <th>Valid Certificate or Invalid</th>
                <th>Which Domains</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><%=data.daysRemaining%></td>
                <td><%=data.valid%></td>
                <td><%=data.validFor%></td>
            </tr>
        </tbody>
    </table>
    <%}%>
</body>
</html>

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply