Преглед изворни кода

Check that certificates are created

Bob Mottram пре 9 година
родитељ
комит
667cfdd3f8
1 измењених фајлова са 19 додато и 0 уклоњено
  1. 19
    0
      src/freedombone-clientcert

+ 19
- 0
src/freedombone-clientcert Прегледај датотеку

@@ -100,12 +100,31 @@ chmod 600 /etc/dovecot/passwd-file
100 100
 # create a user cert
101 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 109
 # create a certificate request
104 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 118
 # sign the certificate request
119
+cd /etc/ssl
107 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 128
 # move the cert to the user's home
110 129
 mkdir /home/$USERNAME/emailcert
111 130
 mv /etc/ssl/certs/$USERNAME.cer /home/$USERNAME/emailcert