Changeset f217af2 for tests


Ignore:
Timestamp:
Feb 18, 2015 10:36:33 PM (5 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
5a7a7ac
Parents:
6d58f9a
Message:

extend checkcerts.sh to print bits and hash information

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/scripts/checkcerts.sh

    r6d58f9a rf217af2  
    2121date2julian() {
    2222    # Julian date conversion adapted from a post (its code released into the public
    23     # domain) by Tapani Tarvainen to comp.unix.shell (1998) for portability
     23    # domain) by Tapani Tarvainen to comp.unix.shell 1998)) for portability
    2424    # (e.g. using 'expr' instead of requiring Bash, ksh, or zsh).
    2525    #   $1 = Month
     
    9191    if [ $OPENSSL ]; then
    9292        # OpenSSL's format: Mar  7 16:08:35 2022 GMT
    93         DATA=$(openssl x509 -enddate -noout -in $1| cut -d'=' -f2-)
     93        DATA=$(openssl x509 -enddate -noout -in $1 | cut -d'=' -f2-)
    9494    else
    9595        # Certtool's format: Mon Mar 07 16:08:35 UTC 2022
     
    100100    fi
    101101    echo $DATA
     102}
     103
     104get_bits() {
     105    if [ $OPENSSL ]; then
     106        BITS=$(openssl x509 -text -noout -in $1 | sed -e '/Public-Key/!d' \
     107            -e 's/\s\+Public-Key: (\([0-9]\+\) bit)/\1 bits/')
     108    else
     109        BITS=$(certtool -i < $1 | sed -e '/^.*Algorithm Security Level/!d' \
     110            -e 's/.*(\([0-9]\+\) bits).*/\1 bits/')
     111    fi
     112}
     113
     114get_sigtype() {
     115    if [ $OPENSSL ]; then
     116        TYPE=$(openssl x509 -text -noout -in $1 | sed -e '/Signature Algorithm/!d' \
     117            -e 's/\s\+Signature Algorithm:\s\+\(.\+\)/\1/' | head -n1)
     118    else
     119        TYPE=$(certtool -i < $1 | sed -e '/^.*Signature Algorithm:/!d' \
     120            -e 's/.*:\s\+\(.*\)/\1/')
     121    fi
    102122}
    103123
     
    165185       compute_dates
    166186    fi
     187    get_bits $i && get_sigtype $i
     188    printf '%s - %s\n\n' "$BITS" "$TYPE"
    167189    if grep '\s$' $i > /dev/null 2>&1; then
    168190        echo "********* Trailing whitespace found in file $i *********"
Note: See TracChangeset for help on using the changeset viewer.