From: Barış Metin Date: Fri, 9 Oct 2009 08:59:02 +0000 (+0000) Subject: do not delete the certificates but keep copies X-Git-Tag: MyPLC-4.3-26~2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=00ce026d1b2662f9579ed5b2a5589c670e000285;p=myplc.git do not delete the certificates but keep copies --- diff --git a/plc.d/ssl b/plc.d/ssl index afdcd22..dd145a6 100755 --- a/plc.d/ssl +++ b/plc.d/ssl @@ -25,6 +25,14 @@ ssl_cname () lower } +backup_file () +{ + filepath=$1 + filename=$(basename ${filepath}) + dir=$(dirname ${filepath}) + mv -f ${filepath} ${dir}/${filename}-`date +%Y-%m-%d-%H-%M-%S`.bak +} + # Verify a certificate. If invalid, generate a new self-signed # certificate. verify_or_generate_certificate() { @@ -42,10 +50,11 @@ verify_or_generate_certificate() { if [ -f $crt ] ; then # Check if certificate is valid verify=$(openssl verify -CAfile $ca $crt) - # Delete if invalid or if the subject has changed + # Backup if invalid or if the subject has changed if grep -q "error" <<<$verify || \ [ "$(ssl_cname $crt)" != "$cname" ] ; then - rm -f $crt $ca + backup_file $crt + backup_file $ca fi fi