-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (24 loc) · 700 Bytes
/
Copy pathindex.js
File metadata and controls
31 lines (24 loc) · 700 Bytes
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
// curl --insecure -v https://uedsky.com -I 2>&1 | grep "expire date"
const https = require('https')
const DAY_SECS = 3600 * 24 * 1000
function checkCert (host) {
return new Promise((resolve, reject) => {
const options = {
hostname: host,
port: 443,
path: '/',
method: 'HEAD',
checkServerIdentity: function (host, cert) {
const valid_to = new Date(cert.valid_to)
const leftDays = (valid_to - Date.now()) / DAY_SECS | 0
resolve(leftDays)
}
}
options.agent = new https.Agent(options)
const req = https.request(options)
req.on('error', reject)
req.end()
})
}
module.exports = checkCert
// vim: ft=javascript