chiark / gitweb /
New role for Debian-specific configuration.
[distorted-ansible] / roles / debian / files / pki / check-x509-certs
CommitLineData
3f6c5992
MW
1#! /bin/sh -e
2
3conf=/etc/ca/check-x509-certs.conf
4time=$(( 7 * 86400 ))
5usage="usage: $0 [-c CONF] [-d DAYS] [-s SECS]"
6
7while getopts c:d:s: opt; do
8 case "$opt" in
9 c) conf=$OPTARG ;;
10 d) time=$(( $OPTARG * 86400 )) ;;
11 s) time=$OPTARG ;;
12 *) echo >&2 "$usage"; exit 1 ;;
13 esac
14done
15shift $(( $OPTIND - 1 ))
16case $# in 0) ;; *) echo >&2 "$usage"; exit 1 ;; esac
17
18if [ ! -f $conf ]; then exit 0; fi
19
20any=nil
21while read line; do
22 case "$line" in "" | "#"*) continue ;; esac
23 file=$line
24 if openssl x509 -in "$file" -noout -checkend $time; then
25 continue
26 fi
27 if openssl x509 -in "$file" -noout -checkend 0; then
28 state="expires soon"
29 else
30 state="ALREADY EXPIRED!"
31 fi
32 case $any in nil) any=t ;; t) echo ;; esac
33 echo "$file: $state"
34 openssl x509 -in "$file" -noout -issuer -dates
35done <"$conf"