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 <njoseph@riseup.net>
[Veiko: Made added code comment more precise]
Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Veiko Aasa 2020-12-26 10:10:53 +02:00
parent 327e76220b
commit 5f3643cc24
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -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