forked from trevor229/MOTD-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
50-ssl
31 lines (24 loc) · 991 Bytes
/
50-ssl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env node
// @author https://www.reddit.com/user/LookAtMyKeyboard
var style = require("ansi-styles");
var sslCertificate = require('get-ssl-certificate');
var redTriangle = style.color.red.open + "▲" + style.color.close;
var greenCircle = style.color.green.open + "●" + style.color.close;
var domains = [
"yourdomainhere.com"
];
console.log("\nSSL Certificates:");
domains.forEach(function(domain){
sslCertificate.get(domain).then(function (certificate) {
// console.log(certificate.valid_from)
// 'Nov 8 00:00:00 2015 GMT'
var expiryDate = new Date(certificate.valid_to);
var indent = "\t";
if (domain.length <=10){ indent = "\t\t";};
console.log(" " + greenCircle + " " + domain + indent + "valid until " + expiryDate.toDateString());
// 'Aug 22 23:59:59 2017 GMT'
console.log("");
}).catch(function(err) {
console.log(" " + redTriangle + " " + domain + " " + err.message);
});
});