Browse Source

Check that certificates are created

Bob Mottram 9 years ago
parent
commit
667cfdd3f8
1 changed files with 19 additions and 0 deletions
  1. 19
    0
      src/freedombone-clientcert

+ 19
- 0
src/freedombone-clientcert View File

100
 # create a user cert
100
 # create a user cert
101
 freedombone-addcert -h $USERNAME --nodh
101
 freedombone-addcert -h $USERNAME --nodh
102
 
102
 
103
+if [ ! -f /etc/ssl/private/$USERNAME.key ]; then
104
+    echo 'User certificates were not created'
105
+    rm -rf /home/$USERNAME/emailcert
106
+    exit 74835
107
+fi
108
+
103
 # create a certificate request
109
 # create a certificate request
104
 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
110
 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
105
 
111
 
112
+if [ ! -f /etc/ssl/requests/$USERNAME.csr ]; then
113
+    echo 'Certificate request was not created'
114
+    rm -rf /home/$USERNAME/emailcert
115
+    exit 83520
116
+fi
117
+
106
 # sign the certificate request
118
 # sign the certificate request
119
+cd /etc/ssl
107
 openssl ca -config /etc/ssl/dovecot-ca.cnf -in /etc/ssl/requests/$USERNAME.csr -out /etc/ssl/certs/$USERNAME.cer
120
 openssl ca -config /etc/ssl/dovecot-ca.cnf -in /etc/ssl/requests/$USERNAME.csr -out /etc/ssl/certs/$USERNAME.cer
108
 
121
 
122
+if [ ! -f /etc/ssl/certs/$USERNAME.cer ]; then
123
+    echo 'Authentication certificate was not created'
124
+    rm -rf /home/$USERNAME/emailcert
125
+    exit 343569
126
+fi
127
+
109
 # move the cert to the user's home
128
 # move the cert to the user's home
110
 mkdir /home/$USERNAME/emailcert
129
 mkdir /home/$USERNAME/emailcert
111
 mv /etc/ssl/certs/$USERNAME.cer /home/$USERNAME/emailcert
130
 mv /etc/ssl/certs/$USERNAME.cer /home/$USERNAME/emailcert