Check that certificates are created

This commit is contained in:
Bob Mottram 2015-06-17 20:18:48 +01:00
parent 369e2a5b2f
commit 667cfdd3f8
1 changed files with 19 additions and 0 deletions

View File

@ -100,12 +100,31 @@ chmod 600 /etc/dovecot/passwd-file
# create a user cert
freedombone-addcert -h $USERNAME --nodh
if [ ! -f /etc/ssl/private/$USERNAME.key ]; then
echo 'User certificates were not created'
rm -rf /home/$USERNAME/emailcert
exit 74835
fi
# create a certificate request
openssl req -new -sha256 -subj "/O=$ORGANISATION/OU=$UNIT/C=$COUNTRY_CODE/ST=$AREA/L=$LOCATION/CN=$USERNAME" -key /etc/ssl/private/$USERNAME.key -out /etc/ssl/requests/$USERNAME.csr
if [ ! -f /etc/ssl/requests/$USERNAME.csr ]; then
echo 'Certificate request was not created'
rm -rf /home/$USERNAME/emailcert
exit 83520
fi
# sign the certificate request
cd /etc/ssl
openssl ca -config /etc/ssl/dovecot-ca.cnf -in /etc/ssl/requests/$USERNAME.csr -out /etc/ssl/certs/$USERNAME.cer
if [ ! -f /etc/ssl/certs/$USERNAME.cer ]; then
echo 'Authentication certificate was not created'
rm -rf /home/$USERNAME/emailcert
exit 343569
fi
# move the cert to the user's home
mkdir /home/$USERNAME/emailcert
mv /etc/ssl/certs/$USERNAME.cer /home/$USERNAME/emailcert