Skip to content

Commit 36c1f46

Browse files
committed
letsencrypt: disable also ncp web certs if OFF
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent dcfd1cf commit 36c1f46

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

bin/ncp/NETWORKING/letsencrypt.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ configure()
5858
rm -f /etc/letsencrypt/renewal-hooks/deploy/ncp
5959
[[ "$DOCKERBUILD" == 1 ]] && update-rc.d letsencrypt disable
6060
install_template nextcloud.conf.sh "${nc_vhostcfg}"
61+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem|" "${vhostcfg2}"
62+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key|" "${vhostcfg2}"
63+
apachectl -k graceful
6164
echo "letsencrypt certificates disabled. Using self-signed certificates instead."
6265
exit 0
6366
}
@@ -110,8 +113,8 @@ EOF
110113

111114
# Configure Apache
112115
install_template nextcloud.conf.sh "${nc_vhostcfg}"
113-
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/fullchain.pem|" $vhostcfg2
114-
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/privkey.pem|" $vhostcfg2
116+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/fullchain.pem|" "${vhostcfg2}"
117+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/letsencrypt/live/$DOMAIN_LOWERCASE/privkey.pem|" "${vhostcfg2}"
115118

116119
# Configure Nextcloud
117120
local domain_index="${TRUSTED_DOMAINS[letsencrypt_1]}"

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
[v1.41.11](https://github.com/nextcloud/nextcloudpi/commit/c95976c) (2021-10-15) ncp-backup: added help message (#1231)
2+
[v1.41.12](https://github.com/nextcloud/nextcloudpi/commit/a41d3d1) (2021-10-20) letsencrypt: disable also ncp web certs if OFF
3+
4+
[v1.41.11](https://github.com/nextcloud/nextcloudpi/commit/dcfd1cf) (2021-10-15) ncp-backup: added help message (#1231)
35

46
[v1.41.10](https://github.com/nextcloud/nextcloudpi/commit/ec94e6f) (2021-10-18) nc-static-IP: use ifdown/ifup
57

etc/ncp-templates/nextcloud.conf.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ if [[ "$1" != "--defaults" ]] && [[ -n "$LETSENCRYPT_DOMAIN" ]]; then
4646
LETSENCRYPT_CERT_BASE_PATH="/etc/letsencrypt/live/${LETSENCRYPT_DOMAIN,,}"
4747

4848
# find the most recent cert otherwise
49-
[[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] || {
49+
[[ -f "${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" ]] || {
5050
LETSENCRYPT_CERT_BASE_PATH="$(find /etc/letsencrypt/live -type d -name "${LETSENCRYPT_DOMAIN,,}*" -printf "%T@ %p\n" | sort -n | cut -f2 -d' ' | tail -1)"
5151
}
5252

53-
# otherwise, in some installs this is the path we use (for legacy reasons)
54-
[[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] || {
53+
# otherwise, in some installs this is the path we use
54+
[[ -f "${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" ]] || {
5555
if [[ -d "/etc/letsencrypt/live/ncp-nextcloud" ]]; then
5656
LETSENCRYPT_CERT_BASE_PATH="/etc/letsencrypt/live/ncp-nextcloud"
5757
fi
@@ -63,7 +63,7 @@ else
6363
fi
6464

6565
# NOTE: we fall back to self-signed snakeoil certs if we couldn't get a LE one
66-
[[ -d "${LETSENCRYPT_CERT_BASE_PATH}" ]] && {
66+
[[ -f "${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem" ]] && [[ -f "${LETSENCRYPT_CERT_BASE_PATH}/privkey.pem" ]] && {
6767
LETSENCRYPT_CERT_PATH="${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem"
6868
LETSENCRYPT_KEY_PATH="${LETSENCRYPT_CERT_BASE_PATH}/privkey.pem"
6969
}
@@ -72,7 +72,7 @@ cat <<EOF
7272
ErrorLog /var/log/apache2/nc-error.log
7373
SSLEngine on
7474
SSLProxyEngine on
75-
SSLCertificateFile ${LETSENCRYPT_CERT_PATH:-/etc/ssl/certs/ssl-cert-snakeoil.pem}
75+
SSLCertificateFile ${LETSENCRYPT_CERT_PATH:-/etc/ssl/certs/ssl-cert-snakeoil.pem}
7676
SSLCertificateKeyFile ${LETSENCRYPT_KEY_PATH:-/etc/ssl/private/ssl-cert-snakeoil.key}
7777
7878
# For notify_push app in NC21

updates/1.40.0.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ source /usr/local/etc/library.sh # sets NCLATESTVER PHPVER RELEASE
1111
# update ncp-restore
1212
install_app nc-restore
1313

14+
# fix ncp.conf bug if LE is disabled
15+
if ! is_active_app letsencrypt; then
16+
if [[ -f /etc/apache2/sites-enabled/ncp.conf ]]; then
17+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem|" /etc/apache2/sites-enabled/ncp.conf
18+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key|" /etc/apache2/sites-enabled/ncp.conf
19+
fi
20+
fi
21+
1422
# fix letsencrypt with httpsonly enabled
1523
cat > /etc/apache2/sites-available/000-default.conf <<'EOF'
1624
<VirtualHost _default_:80>

updates/1.42.0.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ run_app nc-notify-updates
1515
# update nc-backup
1616
install_app nc-backup
1717

18+
# fix ncp.conf bug if LE is disabled
19+
if ! is_active_app letsencrypt; then
20+
if [[ -f /etc/apache2/sites-enabled/ncp.conf ]]; then
21+
sed -i "s|SSLCertificateFile.*|SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem|" /etc/apache2/sites-enabled/ncp.conf
22+
sed -i "s|SSLCertificateKeyFile.*|SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key|" /etc/apache2/sites-enabled/ncp.conf
23+
fi
24+
fi
25+
1826
# docker images only
1927
[[ -f /.docker-image ]] && {
2028
:

0 commit comments

Comments
 (0)