3 [ "$1" == "" ] && echo "Usage: $0 <year>" && exit 1
9 verify(){ # crt, [untrusted], additional
11 [[ "$untrusted" != "" ]] && untrusted="-untrusted $untrusted"
12 openssl verify $3 -CAfile root.ca/key.crt $untrusted "$1" || error "$1 did not verify"
13 echo openssl verify $3 -CAfile root.ca/key.crt $untrusted "$1" || error "$1 did not verify"
21 verifyExtlist() { # ext
22 EXTLIST=`echo "$1" | grep "X509v3\|Authority Information" | sed "s/^[ \t]*//"`
24 X509v3 Certificate Policies: "
25 if [[ $2 == "root" ]]; then
28 VAR="X509v3 extensions:
29 X509v3 Basic Constraints: critical
30 X509v3 Key Usage: critical
31 X509v3 Subject Key Identifier:
32 X509v3 Authority Key Identifier:
33 X509v3 CRL Distribution Points:
34 Authority Information Access: $ADD"
36 diff <(echo "$EXTLIST") <(echo "$VAR") || error "Extensions order is wrong for $2"
41 verify root.ca/key.crt
42 verifyExtlist "$(openssl x509 -in "root.ca/key.crt" -noout -text)" root
44 # Verify level-1 structure
45 for ca in $STRUCT_CAS; do
47 verifyExtlist "$(openssl x509 -in "$ca.ca/key.crt" -noout -text)" "$ca"
50 # Verify level-2 (time) structure
51 for ca in ${STRUCT_CAS}; do
52 for i in $TIME_IDX; do
54 CA_FILE=$year/ca/${ca}_${year}_${i}.crt
56 timestamp=$(date --date="${time:0:2}/${time:2:2}/${year} 03:00:00 UTC" +"%s")
57 verify "$CA_FILE" "$ca.ca/key.crt" "-attime ${timestamp}"
58 EXT=`openssl x509 -in "$CA_FILE" -noout -text`
60 verifyExtlist "$EXT" "$ca-$i"
62 echo "$EXT" | grep "Subject: " | grep "CN=$name" > /dev/null || error "Subject field did not verify"
64 echo "$EXT" | grep -A 2 "Basic Constraints" | grep "CA:TRUE" > /dev/null || error "Basic Constraints field is wrong for $ca"
65 echo "$EXT" | grep -A 2 "Key Usage" | grep "^ *Certificate Sign, CRL Sign$" > /dev/null || error "KeyUsage field is wrong for $ca"
67 echo "$EXT" | grep -A 4 "CRL Distribution" | grep "g2.crl.${DOMAIN}/g2/$ca.crl" > /dev/null || error "CRL field is wrong for $ca"
68 echo "$EXT" | grep "CA Issuers" | grep "/$ca.crt" | grep "g2.crt.${DOMAIN}/g2/" > /dev/null || error "CA Issuers field is wrong for $ca"
69 echo "$EXT" | grep "OCSP" | grep "http://g2.ocsp.${DOMAIN}" > /dev/null || error "OCSP field is wrong for $ca"