bluecherrydvr / bluecherry-apps

Bluecherry surveillance system (server application)
http://www.bluecherrydvr.com
GNU General Public License v2.0
200 stars 64 forks source link

Registering letsencrypt certificates via the web interface does not work on clean installs #635

Open curtishall opened 7 months ago

curtishall commented 7 months ago

certbot is installed in /root/.local/bin/certbot but the scripts are calling 'certbot'.

Command line of how I resolved this:

root@v3demo:~/.local/bin# ./certbot certonly --non-interactive --agree-tos --work-dir=/tmp --logs-dir=/tmp --config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/ --dns-subdomain-provider-credentials /tmp/dns-subdomain-credentials.ini -m chall@corp.bluecherry.app --authenticator dns-subdomain-provider -d demo.bluecherry.app Saving debug log to /tmp/letsencrypt.log Requesting a certificate for demo.bluecherry.app Unsafe permissions on credentials configuration file: /tmp/dns-subdomain-credentials.ini Waiting 10 seconds for DNS changes to propagate

Successfully received certificate. Certificate is saved at: /usr/share/bluecherry/nginx-includes/letsencrypt/live/demo.bluecherry.app/fullchain.pem Key is saved at: /usr/share/bluecherry/nginx-includes/letsencrypt/live/demo.bluecherry.app/privkey.pem This certificate expires on 2024-03-07. These files will be updated when the certificate renews.

NEXT STEPS:

andrey-utkin commented 7 months ago

I haven't reproduced the issue yet, but speculatively, it might be because we don't seem to enforce the presence of admin's email. We could add such a check, or at least do some shell quoting to avoid messing up the arguments order:

--- a/scripts/update_subdomain_certs.sh
+++ b/scripts/update_subdomain_certs.sh
@@ -54,7 +54,7 @@ echo "Generating certs..."
 certbot certonly --non-interactive --agree-tos --work-dir=/tmp --logs-dir=/tmp \
     --config-dir=/usr/share/bluecherry/nginx-includes/letsencrypt/ \
     --dns-subdomain-provider-credentials $credentials \
-    -m $email --authenticator dns-subdomain-provider \
+    -m "$email" --authenticator dns-subdomain-provider \
     -d $subdomain.bluecherry.app -v

 rm $credentials
andrey-utkin commented 6 months ago

Draft fix is in https://github.com/bluecherrydvr/bluecherry-apps/pull/638