├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── checker.sh └── runcheck.sh /.gitignore: -------------------------------------------------------------------------------- 1 | public 2 | tmp 3 | output -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "10" 4 | dist: trusty 5 | install: 6 | - chmod +x ./checker.sh 7 | script: 8 | - ./checker.sh suka.moe www.suka.moe blog.suka.moe lab.suka.moe cdn.suka.moe theme.suka.moe suka.js.org 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 SukkaW 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CheckSSL 2 | 3 | :lock:Check your site's SSL status 4 | 5 | [![Author](https://img.shields.io/badge/Author-Sukka-b68469.svg?style=flat-square)](https://skk.moe) 6 | ![Travis](https://img.shields.io/travis/SukkaLab/ssl.svg?style=flat-square) 7 | [![License](https://img.shields.io/github/license/sukkaw/CheckSSL.svg?style=flat-square)](./LICENSE) 8 | 9 | ## Demo 10 | 11 | https://lab.skk.moe/ssl 12 | 13 | ## Usage 14 | 15 | First clone this repo: 16 | 17 | ```bash 18 | $ git clone https://github.com/SukkaW/CheckSSL.git 19 | $ cd CheckSSL 20 | ``` 21 | 22 | Then give script permission to execute: 23 | 24 | ```bash 25 | $ chmod +x checker.sh 26 | ``` 27 | 28 | Run `checker.sh` with your domain, just like 29 | 30 | ```bash 31 | # Example 32 | $ ./checker.sh skk.moe www.skk.moe blog.skk.moe lab.skk.moe 33 | ``` 34 | 35 | You will get a `ct.json` file at `output` directories. 36 | 37 | ## Output 38 | 39 | Here is an exmaple of `ct.json`: 40 | 41 | ```json 42 | [{ 43 | "domain": "skk.moe", 44 | "subject": "C=US; ST=CA; L=San Francisco; O=CloudFlare, Inc.; CN=sni.cloudflaressl.com", 45 | "start": "2018-09-14 00:00:00 GMT", 46 | "expire": "2019-09-14 12:00:00 GMT", 47 | "issuer": "C=US; ST=CA; L=San Francisco; O=CloudFlare, Inc.; CN=CloudFlare Inc ECC CA-2", 48 | "status": "Valid", 49 | "statuscolor": "success", 50 | "check": "2018-10-20 15:23:54", 51 | "remain": "328" 52 | }, { 53 | "domain": "www.skk.moe", 54 | "subject": "C=US; ST=CA; L=San Francisco; O=CloudFlare, Inc.; CN=sni.cloudflaressl.com", 55 | "start": "2018-09-17 00:00:00 GMT", 56 | "expire": "2019-09-17 12:00:00 GMT", 57 | "issuer": "C=US; ST=CA; L=San Francisco; O=CloudFlare, Inc.; CN=CloudFlare Inc ECC CA-2", 58 | "status": "Valid", 59 | "statuscolor": "success", 60 | "check": "2018-10-20 15:23:54", 61 | "remain": "331" 62 | }] 63 | ``` 64 | 65 | - **domain** - The domain your check 66 | - **subject** - Details of your SSL 67 | - **start** - When your ssl issued 68 | - **expire** - When your ssl expired 69 | - **issuer** - Details of your CA's chain 70 | - **status** - Could be `Valid`, `Invalid`, `Soon Expired`(if it is less than 10d before expired), `Expired` 71 | - **statuscolor** - `success` for Valid, `warning` for Soon Expired and `error` for Expired or Invilid 72 | 73 | > you can work with css framework (such as Bootstrap) using `class="text-${statuscolor}"` 74 | 75 | - **remain** - How many days before your ssl expired 76 | 77 | ## Author 78 | 79 | **CheckSSL** © [Sukka](https://github.com/SukkaW), Released under the [MIT](./LICENSE) License. 80 | 81 | > [Personal Website](https://skk.moe) · [Blog](https://blog.skk.moe) · GitHub [@SukkaW](https://github.com/SukkaW) · Telegram Channel [@SukkaChannel](https://t.me/SukkaChannel) 82 | 83 | -------------------------------------------------------------------------------- /checker.sh: -------------------------------------------------------------------------------- 1 | chmod +x ./runcheck.sh 2 | 3 | mkdir ./tmp/api -p 4 | 5 | for i in $@ 6 | do 7 | ./runcheck.sh ${i} 8 | done 9 | 10 | echo '[' > ./tmp/api/ct.json 11 | 12 | for i in $@ 13 | do 14 | cat ./tmp/${i}.json >> ./tmp/api/ct.json 15 | done 16 | 17 | sed -i '$d' ./tmp/api/ct.json 18 | 19 | echo '}' >> ./tmp/api/ct.json 20 | echo ']' >> ./tmp/api/ct.json 21 | 22 | sed -i ':label;N;s/\n/ /;b label' ./tmp/api/ct.json 23 | 24 | sed -i "s|\" \"||g" ./tmp/api/ct.json 25 | sed -i "s|\"\: \"|\"\:\"|g" ./tmp/api/ct.json 26 | sed -i "s|\"\, \"|\"\,\"|g" ./tmp/api/ct.json 27 | sed -i "s|\" }, { \"|\"},{\"|g" ./tmp/api/ct.json 28 | 29 | mkdir ./output -p 30 | cp -rf ./tmp/api/ct.json ./output/ct.json 31 | 32 | rm -rf ./tmp 33 | -------------------------------------------------------------------------------- /runcheck.sh: -------------------------------------------------------------------------------- 1 | mkdir ./tmp -p 2 | 3 | curl https://${1} -k -v -s -o /dev/null 2> ./tmp/ca.info 4 | 5 | cat ./tmp/ca.info | grep 'start date: ' > ./tmp/${1}.info 6 | cat ./tmp/ca.info | grep 'expire date: ' >> ./tmp/${1}.info 7 | cat ./tmp/ca.info | grep 'issuer: ' >> ./tmp/${1}.info 8 | cat ./tmp/ca.info | grep 'SSL certificate verify' >> ./tmp/${1}.info 9 | cat ./tmp/ca.info | grep 'subject: ' >> ./tmp/${1}.info 10 | 11 | sed -i 's|\* \t start date: ||g' ./tmp/${1}.info 12 | sed -i 's|\* \t expire date: ||g' ./tmp/${1}.info 13 | sed -i 's|\* \t issuer: ||g' ./tmp/${1}.info 14 | sed -i 's|\* \t SSL certificate verify ||g' ./tmp/${1}.info 15 | sed -i 's|\* \t subject: ||g' ./tmp/${1}.info 16 | 17 | start=$(sed -n '1p' ./tmp/${1}.info) 18 | expire=$(sed -n '2p' ./tmp/${1}.info) 19 | issuer=$(sed -n '3p' ./tmp/${1}.info) 20 | status=$(sed -n '4p' ./tmp/${1}.info) 21 | subject=$(sed -n '5p' ./tmp/${1}.info) 22 | 23 | rm -f ./tmp/ca.info 24 | rm -f ./tmp/${1}.info 25 | 26 | DATE="$(echo $(date '+%Y-%m-%d %H:%M:%S'))" 27 | 28 | nowstamp="$(date -d "$DATE" +%s)" 29 | expirestamp="$(date -d "$expire" +%s)" 30 | expireday=`expr $[expirestamp-nowstamp] / 86400` 31 | 32 | echo '{' > tmp/${1}.json 33 | echo '"domain": "'${1}'",' >> ./tmp/${1}.json 34 | echo '"subject": "'$subject'",' >> ./tmp/${1}.json 35 | echo '"start": "'$start'",' >> ./tmp/${1}.json 36 | echo '"expire": "'$expire'",' >> ./tmp/${1}.json 37 | echo '"issuer": "'$issuer'",' >> ./tmp/${1}.json 38 | 39 | if [ $expirestamp \< $nowstamp ]; then 40 | echo '"status": "Expired",' >> ./tmp/${1}.json 41 | echo '"statuscolor": "error",' >> ./tmp/${1}.json 42 | elif [ $expireday \< 10 ]; then 43 | echo '"status": "Soon Expired",' >> ./tmp/${1}.json 44 | echo '"statuscolor": "warning",' >> ./tmp/${1}.json 45 | elif [ $status = "ok." ]; then 46 | echo '"status": "Valid",' >> ./tmp/${1}.json 47 | echo '"statuscolor": "success",' >> ./tmp/${1}.json 48 | else 49 | echo '"status": "Invalid",' >> ./tmp/${1}.json 50 | echo '"statuscolor": "error",' >> ./tmp/${1}.json 51 | fi 52 | 53 | echo '"check": "'$DATE'",' >> ./tmp/${1}.json 54 | echo '"remain": "'$expireday'"' >> ./tmp/${1}.json 55 | echo '},' >> ./tmp/${1}.json 56 | --------------------------------------------------------------------------------