Parcourir la source

Checking that certs exist

Bob Mottram il y a 8 ans
Parent
révision
75b27e65dc
2 fichiers modifiés avec 22 ajouts et 8 suppressions
  1. 20
    6
      src/freedombone-app-xmpp
  2. 2
    2
      src/freedombone-utils-web

+ 20
- 6
src/freedombone-app-xmpp Voir le fichier

@@ -310,7 +310,7 @@ function install_xmpp_main {
310 310
     fi
311 311
 
312 312
     # obtain a cert for the default domain
313
-    if [ ! -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
313
+    if [[ $(cert_exists ${DEFAULT_DOMAIN_NAME} pem) == "0" ]]; then
314 314
         echo $'Obtaining certificate for the main domain'
315 315
         create_site_certificate ${DEFAULT_DOMAIN_NAME} 'yes'
316 316
     fi
@@ -339,9 +339,9 @@ function install_xmpp_main {
339 339
     fi
340 340
 
341 341
     # create a certificate
342
-    if [ ! -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
343
-        if [ ! -f /etc/ssl/certs/xmpp.dhparam ]; then
344
-            ${PROJECT_NAME}-addcert -h xmpp --dhkey $DH_KEYLENGTH
342
+    if [[ $(cert_exists ${DEFAULT_DOMAIN_NAME} pem) == "0" ]]; then
343
+        if [[ $(cert_exists ${DEFAULT_DOMAIN_NAME} xmpp) == "0" ]]; then
344
+            ${PROJECT_NAME}-addcert -h xmpp --dhkey ${DH_KEYLENGTH}
345 345
             check_certificates xmpp
346 346
         fi
347 347
     fi
@@ -349,7 +349,7 @@ function install_xmpp_main {
349 349
     chown prosody:prosody /etc/ssl/certs/xmpp.*
350 350
     cp -a /etc/prosody/conf.avail/example.com.cfg.lua /etc/prosody/conf.avail/xmpp.cfg.lua
351 351
 
352
-    if [ -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
352
+    if [[ $(cert_exists ${DEFAULT_DOMAIN_NAME} pem) == "1" ]]; then
353 353
         sed -i "s|/etc/prosody/certs/example.com.key|/etc/ssl/private/${DEFAULT_DOMAIN_NAME}.key|g" /etc/prosody/conf.avail/xmpp.cfg.lua
354 354
         sed -i "s|/etc/prosody/certs/example.com.crt|/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem|g" /etc/prosody/conf.avail/xmpp.cfg.lua
355 355
     else
@@ -357,7 +357,7 @@ function install_xmpp_main {
357 357
         sed -i 's|/etc/prosody/certs/example.com.crt|/etc/ssl/certs/xmpp.crt|g' /etc/prosody/conf.avail/xmpp.cfg.lua
358 358
     fi
359 359
     if ! grep -q "xmpp.dhparam" /etc/prosody/conf.avail/xmpp.cfg.lua; then
360
-        if [ -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam ]; then
360
+        if [[ $(cert_exists ${DEFAULT_DOMAIN_NAME}) == "1" ]]; then
361 361
             sed -i "/certificate =/a\        dhparam = \"/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.dhparam\";" /etc/prosody/conf.avail/xmpp.cfg.lua
362 362
         else
363 363
             sed -i '/certificate =/a\        dhparam = "/etc/ssl/certs/xmpp.dhparam";' /etc/prosody/conf.avail/xmpp.cfg.lua
@@ -451,6 +451,20 @@ function install_xmpp_main {
451 451
     fi
452 452
     sed -i "s/example.com/$DEFAULT_DOMAIN_NAME/g" /etc/prosody/prosody.cfg.lua
453 453
 
454
+    if [ $XMPP_DOMAIN_CODE ]; then
455
+        if [ ${#XMPP_DOMAIN_CODE} -gt 0 ]; then
456
+            if [[ $(cert_exists chat.${DEFAULT_DOMAIN_NAME} pem) == "1" ]]; then
457
+                sed -i 's|--Component "conference.|Component "chat.|g' /etc/prosody/prosody.cfg.lua
458
+            fi
459
+            if [[ $(cert_exists xmpp.${DEFAULT_DOMAIN_NAME} pem) == "1" ]]; then
460
+                sed -i 's|--Component "conference.|Component "xmpp.|g' /etc/prosody/prosody.cfg.lua
461
+            fi
462
+            if [[ $(cert_exists conference.${DEFAULT_DOMAIN_NAME} pem) == "1" ]]; then
463
+                sed -i 's|--Component "conference.|Component "conference.|g' /etc/prosody/prosody.cfg.lua
464
+            fi
465
+        fi
466
+    fi
467
+
454 468
     systemctl restart prosody
455 469
     touch /home/$MY_USERNAME/README
456 470
 

+ 2
- 2
src/freedombone-utils-web Voir le fichier

@@ -234,7 +234,7 @@ function create_site_certificate {
234 234
     fi
235 235
 
236 236
     if [[ $ONION_ONLY == "no" ]]; then
237
-        if [[ $(cert_exists) == "0" ]]; then
237
+        if [[ $(cert_exists $SITE_DOMAIN_NAME) == "0" ]]; then
238 238
             if [[ $LETSENCRYPT_ENABLED != "yes" ]]; then
239 239
                 create_self_signed_cert
240 240
             else
@@ -242,7 +242,7 @@ function create_site_certificate {
242 242
             fi
243 243
         else
244 244
             if [[ $LETSENCRYPT_ENABLED == "yes" ]]; then
245
-                if [[ $(cert_exists pem) == "0" ]]; then
245
+                if [[ $(cert_exists $SITE_DOMAIN_NAME pem) == "0" ]]; then
246 246
                     create_letsencrypt_cert
247 247
                 fi
248 248
             fi