]> WPIA git - nre.git/blob - generateCRLs
upd: adjust duration of server certificates
[nre.git] / generateCRLs
1 #!/bin/bash
2
3 set -e
4
5 [ "$1" == "" ] && echo "Usage: $0 <year>" && exit 1
6 year=$1
7
8 . structure.bash
9 . commonFunctions.bash
10 cd generated
11
12 generateCRL() { # name, year, month
13     echo CRL $1 $2-$3
14     BASE="$PWD"
15     pushd $1.ca > /dev/null
16     TZ=UTC LD_PRELOAD="$(findLibfaketime)" FAKETIME="${year}-${month}-01 00:00:00" openssl ca -gencrl -config "$BASE/../selfsign.config" -keyfile key.key -cert key.crt -crldays 35 -out $2_$3.crl
17     popd > /dev/null
18 }
19
20 generateCRLs (){ #name start
21     [[ "$2" == "" ]] && start=$(echo {01..12})
22     [[ "$2" == "07" ]] && start=$(echo {07..12})
23     for month in $start; do
24         generateCRL "$1" "$year" "$month"
25     done
26 }
27
28 generateYearCRLs (){ #name idx
29     [[ "$2" == "1" ]] && start=$(echo {01..12})
30     [[ "$2" == "2" ]] && start=$(echo {07..12})
31     for month in $start; do
32         generateCRL "$1" "$year" "$month"
33     done
34     [[ "$2" == "1" ]] && start=$(echo {01..12})
35     [[ "$2" == "2" ]] && start=$(echo {01..12})
36     for month in $start; do
37         generateCRL "$1" "$((year+1))" "$month"
38     done
39     [[ "$2" == "1" ]] && return
40     [[ "$2" == "2" ]] && start=$(echo {01..06})
41     for month in $start; do
42         generateCRL "$1" "$((year+2))" "$month"
43     done
44 }
45 generateCRLs root
46 for ca in "${STRUCT_CAS[@]}"; do
47     generateCRLs $ca
48 done