Cert Fixes

This commit is contained in:
2026-09-07 10:01:49 +10:00
parent fc2898083c
commit 511929d579
3 changed files with 35 additions and 5 deletions
+19 -3
View File
@@ -271,9 +271,25 @@ HOST_PORT=8443
HTTPS_PUBLIC_PORT=8443
```
An address that isn't listed produces a browser warning. Change the list and restart; the
certificate reissues itself automatically, and devices that already trust the authority accept
it without any further work.
An address that isn't listed produces a browser warning.
After changing anything in `.env`, bring the container back with **`docker compose up -d`**, not
`docker compose restart`. Restart reuses the running container along with the environment it
started with, so the edit appears to do nothing; `up -d` recreates it and picks the new values
up. Confirm with:
```bash
docker compose exec visitor-signin printenv HTTPS_HOSTNAMES
docker compose logs --tail=20 visitor-signin | grep tls
```
The log should say `renewing the server certificate: HTTPS_HOSTNAMES changed` and then list every
name it now covers. If it lists only `localhost`, `visitors.local` and a `172.x` address, the
variable never reached the container — those are the defaults plus the container's own docker
bridge address.
Reissuing does **not** touch the certificate authority, so devices that already trust it keep
working and no MDM profile needs redeploying.
The kiosk is then at `https://visitors.local:8443`, admin at `https://visitors.local:8443/admin`.
+4 -2
View File
@@ -25,8 +25,10 @@ fi
if docker compose ps --status running 2>/dev/null | grep -q visitor-signin; then
docker compose exec -T visitor-signin node scripts/make-cert.mjs $FORCE
echo "Restarting so the new certificate is served..."
docker compose restart visitor-signin
echo "Recreating the container so the new certificate is served..."
# up -d rather than restart: restart keeps the environment the container was
# started with, so an edited .env would be ignored.
docker compose up -d visitor-signin
else
node scripts/make-cert.mjs $FORCE
fi
+12
View File
@@ -194,6 +194,18 @@ export function ensureCertificates({ force = false } = {}) {
fs.writeFileSync(p.names, JSON.stringify(config.https.hostnames));
}
// A very common mistake is editing .env and then using `docker compose restart`,
// which reuses the old environment. The symptom is a certificate covering only
// the defaults, so say so rather than letting it fail later in a browser.
const configured = config.https.hostnames;
if (configured.length === 1 && configured[0] === 'visitors.local') {
console.warn(
'[tls] HTTPS_HOSTNAMES is at its default. If you set it in .env, bring the container\n' +
' back with "docker compose up -d" rather than "docker compose restart" — restart\n' +
' keeps the environment the container started with.'
);
}
return {
key: fs.readFileSync(p.key),
cert: fs.readFileSync(p.cert),