Merge pull request #6701 from nextcloud/enh/noid/allow-add-trusted-certs

nextcloud: allow to add  custom certs to Nextcloud's trusted cert store
This commit is contained in:
Simon L. 2025-08-11 16:00:33 +02:00 committed by GitHub
commit fb8a6bdebf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -578,6 +578,24 @@ else
fi
# AIO app end # Do not remove or change this line!
# Allow to add custom certs to Nextcloud's trusted cert store
if env | grep -q NEXTCLOUD_TRUSTED_CERTIFICATES_; then
set -x
TRUSTED_CERTIFICATES="$(env | grep NEXTCLOUD_TRUSTED_CERTIFICATES_ | grep -oP '^[A-Z_a-z0-9]+')"
mapfile -t TRUSTED_CERTIFICATES <<< "$TRUSTED_CERTIFICATES"
CERTIFICATES_ROOT_DIR="/var/www/html/data/certificates"
mkdir -p "$CERTIFICATES_ROOT_DIR"
for certificate in "${TRUSTED_CERTIFICATES[@]}"; do
# shellcheck disable=SC2001
CERTIFICATE_NAME="$(echo "$certificate" | sed 's|^NEXTCLOUD_TRUSTED_CERTIFICATES_||')"
if ! [ -f "$CERTIFICATES_ROOT_DIR/$CERTIFICATE_NAME" ]; then
echo "${!certificate}" > "$CERTIFICATES_ROOT_DIR/$CERTIFICATE_NAME"
php /var/www/html/occ security:certificates:import "$CERTIFICATES_ROOT_DIR/$CERTIFICATE_NAME"
fi
done
set +x
fi
# Notify push
if ! [ -d "/var/www/html/custom_apps/notify_push" ]; then
php /var/www/html/occ app:install notify_push