From: Felix Dörre Date: Tue, 7 Apr 2015 07:50:58 +0000 (+0200) Subject: upd: verify more closely X-Git-Url: https://code.wpia.club/?p=nre.git;a=commitdiff_plain;h=50e191e92aee247a9c4393c24d98202e845fd419 upd: verify more closely --- diff --git a/verify.sh b/verify.sh index 9d4527a..f698e0d 100755 --- a/verify.sh +++ b/verify.sh @@ -16,12 +16,28 @@ error() { # message exit -1 } +verifyExtlist() { # ext + EXTLIST=`echo "$1" | grep "X509v3\|Authority Information" | sed "s/^[ \t]*//"` + VAR="X509v3 extensions: +X509v3 Basic Constraints: $2 +X509v3 Key Usage: +${3}X509v3 Subject Key Identifier: +X509v3 Authority Key Identifier: +X509v3 CRL Distribution Points: +Authority Information Access: " + + diff <(echo "$EXTLIST" | dos2unix) <(echo "$VAR" | dos2unix) || error "Extensions order is wrong for $ca" + +} + # Verify root verify root.ca/key.crt +verifyExtlist "$(openssl x509 -in "root.ca/key.crt" -noout -text)" # Verify level-1 structure for ca in $STRUCT_CAS; do verify $ca.ca/key.crt + verifyExtlist "$(openssl x509 -in "$ca.ca/key.crt" -noout -text)" done # Verify level-2 (time) structure @@ -36,8 +52,18 @@ for ca in ${STRUCT_CAS}; do time=${points[${i}]} timestamp=$(date --date="${time:0:2}/${time:2:2}/${year} 03:00:00 UTC" +"%s") verify "$CA_FILE" "$ca.ca/key.crt" "-attime ${timestamp}" - openssl x509 -in "$CA_FILE" -noout -text | grep "CA Issuers" | grep "/$ca.crt" > /dev/null || error "CA Issuers field is wrong for $ca" - openssl x509 -in "$CA_FILE" -noout -text | grep "Subject: " | grep "CN=$name" > /dev/null || error "Subject field did not verify" + EXT=`openssl x509 -in "$CA_FILE" -noout -text` + + verifyExtlist "$EXT" + + echo "$EXT" | grep "Subject: " | grep "CN=$name" > /dev/null || error "Subject field did not verify" + + echo "$EXT" | grep -A 2 "Basic Constraints" | grep "CA:TRUE" > /dev/null || error "Basic Constraints field is wrong for $ca" + echo "$EXT" | grep -A 2 "Key Usage" | grep "^ *Certificate Sign, CRL Sign$" > /dev/null || error "KeyUsage field is wrong for $ca" + + echo "$EXT" | grep -A 4 "CRL Distribution" | grep "g2.crl.cacert.org/g2/$ca.crl" > /dev/null || error "CRL field is wrong for $ca" + echo "$EXT" | grep "CA Issuers" | grep "/$ca.crt" | grep "g2.crt.cacert.org/g2/" > /dev/null || error "CA Issuers field is wrong for $ca" + echo "$EXT" | grep "OCSP" | grep "http://g2.ocsp.cacert.org" > /dev/null || error "OCSP field is wrong for $ca" done done @@ -46,6 +72,8 @@ cat env.ca/key.crt $year/ca/env_${year}_1.ca/key.crt > envChain.crt for key in $SERVER_KEYS; do verify ${year}/keys/$key.crt envChain.crt + verifyExtlist "$(openssl x509 -in "${year}/keys/$key.crt" -noout -text)" critical "X509v3 Extended Key Usage: +" done rm envChain.crt