From 5f3643cc24ed949185c0e42a937a676e63abc374 Mon Sep 17 00:00:00 2001 From: Veiko Aasa Date: Sat, 26 Dec 2020 10:10:53 +0200 Subject: [PATCH] apache: Create snake oil certificate if not exists When FreedomBox package is installed on a fresh Debian machine where a snakeoil certificate doesn't exist, generate a new one. Fixes #1923 Fixes #1999 Signed-off-by: Joseph Nuthalapati [Veiko: Made added code comment more precise] Signed-off-by: Veiko Aasa Reviewed-by: Veiko Aasa --- actions/apache | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/actions/apache b/actions/apache index a888acac9..6b64c95c6 100755 --- a/actions/apache +++ b/actions/apache @@ -7,6 +7,7 @@ Configuration helper for Apache web server. import argparse import glob +import os import re import subprocess @@ -97,6 +98,11 @@ def subcommand_setup(arguments): subprocess.run([ 'make-ssl-cert', 'generate-default-snakeoil', '--force-overwrite' ], check=True) + # In case the certificate has been removed after ssl-cert is installed + # on a fresh Debian machine. + elif not os.path.exists('/etc/ssl/certs/ssl-cert-snakeoil.pem'): + subprocess.run(['make-ssl-cert', 'generate-default-snakeoil'], + check=True) with action_utils.WebserverChange() as webserver: # Disable mod_php as we have switched to mod_fcgi + php-fpm. Disable