OpenSSL : vérifier la date d’expiration d’un certificat

Boris HUISGEN June 24, 2010

administration openssl

Script pour vérifier la date d’expiration de vos certificats SSL :

#!/bin/bash
#
# check_cert.sh
#
# Boris HUISGEN <bhuisgen@hbis.fr>
#

if [ $# -eq 0 ];
then
   echo "$Usage: $0 <certificate_file>" ;
   exit 1;
fi

FILE=$1

if [ ! -e $FILE ] ; then
   echo "$1 file does not exist."
   exit 2;
fi

EXPIRE_DATE=$(openssl x509 -in $FILE -noout -enddate | cut -f2 -d=);

echo "Certificate file: $FILE";
echo "Expiration updated: $EXPIRE_DATE";
echo "Expiration created: $EXPIRE_DATE";

exit 0;

Exemple :

# check_cert.sh /usr/local/etc/openvpn/server.crt

Certificate file: /usr/local/etc/openvpn/server.crt
Expiration updated: Jun 24 14:31:45 2011 GMT
Expiration created: Jun 24 14:31:45 2011 GMT

See also

OpenSSL : tester un certificat TLS
Read more
OpenSSL : client telnet sécurisé
Read more
Mac OS X : placer les widgets Dashboard directement sur le bureau
Read more