forked from SukkaW/CheckSSL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruncheck.sh
More file actions
executable file
·56 lines (46 loc) · 1.9 KB
/
runcheck.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.9 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
mkdir ./tmp -p
curl https://${1} -k -v -s -m 10 -o /dev/null 2>./tmp/ca.info
cat ./tmp/ca.info | grep 'start date: ' >./tmp/${1}.info
cat ./tmp/ca.info | grep 'expire date: ' >>./tmp/${1}.info
cat ./tmp/ca.info | grep 'issuer: ' >>./tmp/${1}.info
cat ./tmp/ca.info | grep 'SSL certificate verify' >>./tmp/${1}.info
cat ./tmp/ca.info | grep 'subject: ' >>./tmp/${1}.info
sed -i 's/\* start date: //g' ./tmp/${1}.info
sed -i 's/\* expire date: //g' ./tmp/${1}.info
sed -i 's/\* issuer: //g' ./tmp/${1}.info
sed -i 's/\* SSL certificate verify //g' ./tmp/${1}.info
sed -i 's/\* subject: //g' ./tmp/${1}.info
start=$(sed -n '1p' ./tmp/${1}.info)
expire=$(sed -n '2p' ./tmp/${1}.info)
issuer=$(sed -n '3p' ./tmp/${1}.info)
status=$(sed -n '4p' ./tmp/${1}.info)
subject=$(sed -n '5p' ./tmp/${1}.info)
rm -f ./tmp/ca.info
rm -f ./tmp/${1}.info
DATE="$(echo $(date '+%Y-%m-%d %H:%M:%S'))"
nowstamp="$(date -d "$DATE" +%s)"
expirestamp="$(date -d "$expire" +%s)"
expireday=$(expr $((expirestamp - nowstamp)) / 86400)
echo '{' >tmp/${1}.json
echo '"domain": "'${1}'",' >>./tmp/${1}.json
echo '"subject": "'$subject'",' >>./tmp/${1}.json
echo '"start": "'$start'",' >>./tmp/${1}.json
echo '"expire": "'$expire'",' >>./tmp/${1}.json
echo '"issuer": "'$issuer'",' >>./tmp/${1}.json
if [ $expirestamp \< $nowstamp ]; then
echo '"status": "Expired",' >>./tmp/${1}.json
echo '"statuscolor": "error",' >>./tmp/${1}.json
elif [ $expireday \< 10 ]; then
echo '"status": "Soon Expired",' >>./tmp/${1}.json
echo '"statuscolor": "warning",' >>./tmp/${1}.json
elif [ $status = "ok." ]; then
echo '"status": "Valid",' >>./tmp/${1}.json
echo '"statuscolor": "success",' >>./tmp/${1}.json
else
echo '"status": "Invalid",' >>./tmp/${1}.json
echo '"statuscolor": "error",' >>./tmp/${1}.json
fi
echo '"check": "'$DATE'",' >>./tmp/${1}.json
echo '"remain": "'$expireday'"' >>./tmp/${1}.json
echo '},' >>./tmp/${1}.json