wok-4.x diff cacerts/stuff/remove-expired-certs.sh @ rev 12473

Up openssl 1.0.2u, zlib 1.2.13, tar 1.34, add cacerts, fix git receipt
author Stanislas Leduc <shann@slitaz.org>
date Sat Mar 04 08:15:16 2023 +0000 (15 months ago)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/cacerts/stuff/remove-expired-certs.sh	Sat Mar 04 08:15:16 2023 +0000
     1.3 @@ -0,0 +1,53 @@
     1.4 +#!/bin/sh
     1.5 +# Begin remove-expired-certs.sh
     1.6 +#
     1.7 +# Version 20120211
     1.8 +
     1.9 +# Make sure the date is parsed correctly on all systems
    1.10 +mydate()
    1.11 +{
    1.12 +  local y=$( echo $1 | cut -d" " -f4 )
    1.13 +  local M=$( echo $1 | cut -d" " -f1 )
    1.14 +  local d=$( echo $1 | cut -d" " -f2 )
    1.15 +  local m
    1.16 +
    1.17 +  if [ ${d} -lt 10 ]; then d="0${d}"; fi
    1.18 +
    1.19 +  case $M in
    1.20 +    Jan) m="01";;
    1.21 +    Feb) m="02";;
    1.22 +    Mar) m="03";;
    1.23 +    Apr) m="04";;
    1.24 +    May) m="05";;
    1.25 +    Jun) m="06";;
    1.26 +    Jul) m="07";;
    1.27 +    Aug) m="08";;
    1.28 +    Sep) m="09";;
    1.29 +    Oct) m="10";;
    1.30 +    Nov) m="11";;
    1.31 +    Dec) m="12";;
    1.32 +  esac
    1.33 +
    1.34 +  certdate="${y}${m}${d}"
    1.35 +}
    1.36 +
    1.37 +OPENSSL=/usr/bin/openssl
    1.38 +DIR=$DESTDIR/etc/ssl/certs
    1.39 +
    1.40 +if [ $# -gt 0 ]; then
    1.41 +  DIR="$1"
    1.42 +fi
    1.43 +
    1.44 +certs=$( find ${DIR} -type f -name "*.pem" -o -name "*.crt" )
    1.45 +today=$( date +%Y%m%d )
    1.46 +
    1.47 +for cert in $certs; do
    1.48 +  notafter=$( $OPENSSL x509 -enddate -in "${cert}" -noout )
    1.49 +  date=$( echo ${notafter} |  sed 's/^notAfter=//' )
    1.50 +  mydate "$date"
    1.51 +
    1.52 +  if [ ${certdate} -lt ${today} ]; then
    1.53 +     echo "${cert} expired on ${certdate}! Removing..."
    1.54 +     rm -f "${cert}"
    1.55 +  fi
    1.56 +done