From 7efacfa3bba08788902d1d43e8148930a8dc48c6 Mon Sep 17 00:00:00 2001 From: Slawomir Koszewski Date: Tue, 24 Nov 2026 18:23:42 +0100 Subject: [PATCH] fix: a configuration that names no HTTPS certificate source gets the first setup's choice, and the development VM of lm-dev-vm.py is named by --fqdn, so its HTTPS sites answer a name that resolves to it. --- ADR.md | 7 +++++-- CHANGELOG.md | 14 ++++++++++++++ README.md | 8 +++++--- bin/lm-dev-vm.py | 11 ++++++++--- debian-package/src/usr/lib/linux-manager/setup | 3 +++ docs/certificates.md | 3 ++- tests/remote/README.md | 7 +++++-- tests/remote/configs/dev.json | 2 +- 8 files changed, 43 insertions(+), 12 deletions(-) diff --git a/ADR.md b/ADR.md index 8d10c5d..bc61396 100644 --- a/ADR.md +++ b/ADR.md @@ -1704,8 +1704,11 @@ appliances, and ACME is used only when it is set to `acme`: a public name that r server and port 80 reachable from the internet are rarely ready when a server is installed. The file a new installation writes has it empty, and that installation's first setup chooses it and writes it into the file: `ca` when the Servers Issuing CA has its certificate after the PKI is -provisioned, as with a root the server creates, else `self-signed`. An upgrade makes no choice: a -configuration that names a source keeps it, and one that names none is self-signed. Whether +provisioned, as with a root the server creates, else `self-signed`. Until a setup run has +succeeded, a file that does not set it is taken as empty, so a configuration written by hand or by +a tool in place of the installer's file gets the same choice. An upgrade makes no choice: a +configuration that names a source keeps it, and once a run has succeeded, one that names none is +self-signed. Whether HTTPS is on is an installer question and is always respected, and so is `https.disable_auto_redirect`, which keeps Caddy's plain HTTP site of the Manager from redirecting to HTTPS (ADR-21). diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b17ff7..fd195da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.44.1 - 2026-11-24 18:23:42 +0100 + +fix: a configuration that names no HTTPS certificate source gets the first setup's choice, and the +development VM of lm-dev-vm.py is named by --fqdn, so its HTTPS sites answer a name that resolves +to it. + +- Until a setup run has succeeded, a linux-manager.json without https.certificate, such as one + written in place of the installer's, is taken as empty: the first setup chooses ca when the + Servers Issuing CA has its certificate, else self-signed, and writes it into the file. On a + server already set up, a file without it stays self-signed. +- lm-dev-vm.py --fqdn (LXD_DEV_FQDN, lm-dev.test by default) is the VM's wan.local_fqdn, the + placeholder @FQDN@ of tests/remote/configs/dev.json, and the name of the HTTPS addresses it + prints. + ## 0.44.0 - 2026-11-24 18:06:34 +0100 feature: the CA certificates and CRLs are always published over HTTP and HTTPS on the status and diff --git a/README.md b/README.md index 27d4ce8..2f50b78 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ must have the type shown below; an unknown section or setting is an error. | `https` | `web_port` | integer | `7444` | HTTPS port of the status web service | | `https` | `manager_port` | integer | `7443` | HTTPS port of the Manager | | `https` | `disable_auto_redirect` | boolean | `false` | The Manager answers on its plain HTTP port instead of redirecting there to its HTTPS address while `enabled` is `true`; the status page never redirects | -| `https` | `certificate` | string | `self-signed` | Where the certificate of `wan.local_fqdn` comes from: `self-signed`, `ca`, `acme` or `external`; empty in a new installation's file, for its first setup to choose `ca` or `self-signed` and write it here (see HTTPS) | +| `https` | `certificate` | string | `self-signed` | Where the certificate of `wan.local_fqdn` comes from: `self-signed`, `ca`, `acme` or `external`; empty in a new installation's file, or absent before the first successful setup, for its first setup to choose `ca` or `self-signed` and write it here (see HTTPS) | | `https` | `self_signed_days` | integer | `365` | Days the self-signed certificate is valid, 1 to 3650 | | `https` | `acme_provider` | string | `letsencrypt` | The ACME CA of the server and of the web sites with `tls` `acme`: `letsencrypt`, `zerossl` or `custom` (see HTTPS) | | `https` | `acme_url` | string | | The `https://` ACME directory URL of `custom` | @@ -1639,11 +1639,13 @@ is on or not. ### The server's certificate `https.certificate` says where the certificate of `wan.local_fqdn` comes from; it is `self-signed` -when the file does not set it, and ACME only when it is set to `acme`. The file a new installation +when the file of a server already set up does not set it, and ACME only when it is set to `acme`. The file a new installation writes has it empty, and that installation's first setup chooses it and writes it into the file: `ca` when the root CA and the Servers Issuing CA are available, as with a root the server creates, else `self-signed`, as with an offline root, a Simple CA root that has not signed yet, or a -directory that cannot be reached. A source chosen later, in the Manager or the file, stays. +directory that cannot be reached. Until a setup run has succeeded, a file that does not set it, +such as one written in place of the installer's, gets the same choice. A source chosen later, in +the Manager or the file, stays. | Source | The certificate | |---|---| diff --git a/bin/lm-dev-vm.py b/bin/lm-dev-vm.py index 4105d3f..46b7043 100755 --- a/bin/lm-dev-vm.py +++ b/bin/lm-dev-vm.py @@ -11,7 +11,9 @@ engine made from the file's otp_url, unless --no-otp is given; lm-dev-otp-code.p otp_url the file lacks, or all of them when there is no file, is generated and kept in the file, so a VM made again has the same password and token until they are deleted from the file. The VM gets a configuration from tests/remote/configs/ (--config, dev.json by default), whose @ETH0@ is the -interface of its default route, @CIDR0@ its network and @PSK@ a generated key. The VM gets an AppRole of its own in the project's Vault +interface of its default route, @CIDR0@ its network, @FQDN@ --fqdn (LXD_DEV_FQDN, lm-dev.test by default), and @PSK@ a +generated key; the Manager and the status web service answer HTTPS for that name, which has to resolve to the +listen address. The VM gets an AppRole of its own in the project's Vault (lm_dev.enrol_instance), with which it reads the debconf preseed with the admin's password and the configuration with its key, kept there as VM/preseed and VM/config, and its TOTP key, generated or from otp_url; no secret is an argument or on standard input, so create needs a project with a Vault @@ -60,6 +62,8 @@ def main(): parser.add_argument('--listen', default=setting('LXD_LISTEN', None), help="outside a test project, the LXD host address the proxies listen on (LXD_LISTEN, " "default the IPv4 address of the remote URL's host)") + parser.add_argument('--fqdn', default=setting('LXD_DEV_FQDN', 'lm-dev.test'), + help='the name of the VM in its configuration, @FQDN@ (LXD_DEV_FQDN, default lm-dev.test)') parser.add_argument('--forward-address', default=setting('LXD_FORWARD_ADDRESS', None), help="with create in a test project, the forward's listen address, one of the uplink's routes " "(LXD_FORWARD_ADDRESS); without it one is allocated") @@ -229,7 +233,8 @@ def main(): sys.exit(f'the package did not install; see {log}') # Apply the configuration twice, as the server's certificates follow the first run. - text = config.read_text(encoding='utf-8').replace('@ETH0@', nic).replace('@CIDR0@', str(interface.network)) + text = config.read_text(encoding='utf-8').replace('@ETH0@', nic).replace('@CIDR0@', str(interface.network))\ + .replace('@FQDN@', args.fqdn) problem = hand_over(args.remote, args.project, args.vm, vault, 'config', text.replace('@PSK@', psk), '/etc/linux-manager/linux-manager.json', '0600') if problem: @@ -248,7 +253,7 @@ def main(): if not args.no_otp: print(f'administrator TOTP: otp_url in {credentials}; codes: bin/lm-dev-otp-code.py --project {args.project} ' f'--vm {args.vm}') - print(f'manager: https://{args.listen}:7443/ status: https://{args.listen}:7444/ and http://{args.listen}:7081/ ' + print(f'manager: https://{args.fqdn}:7443/ status: https://{args.fqdn}:7444/ and http://{args.listen}:7081/ ' f'ssh: {args.listen} port 2222') print(f'shell: lxc exec {args.remote}:{args.vm} --project {args.project} -- su -l') print(f'remove: {sys.argv[0]} remove --remote {args.remote} --project {args.project} --vm {args.vm}') diff --git a/debian-package/src/usr/lib/linux-manager/setup b/debian-package/src/usr/lib/linux-manager/setup index d993dee..3b28a52 100755 --- a/debian-package/src/usr/lib/linux-manager/setup +++ b/debian-package/src/usr/lib/linux-manager/setup @@ -1095,6 +1095,9 @@ def main(): f'set general.platform in {linuxmanager.CONFIG_FILE}') progress('deferred', 'configuration', f'general.platform is none; set it in {linuxmanager.CONFIG_FILE}') return 0 + # Until a run has succeeded, a file that names no HTTPS certificate source leaves the choice to this run. + if not SETUP_DONE.exists() and not linuxmanager.read_settings().get('https', {}).get('certificate'): + cfg['https']['certificate'] = '' # The directory holds the PKI, which the configuration needs; its problem ends setup only after every other step. failed_step = 'user directory' diff --git a/docs/certificates.md b/docs/certificates.md index 7e75e4d..2a143c0 100644 --- a/docs/certificates.md +++ b/docs/certificates.md @@ -52,7 +52,8 @@ chosen certificate is available, the server serves a self-signed one and warns. The source is self-signed unless the configuration names another; ACME is used only when it is chosen. The first setup of a new installation chooses the Servers Issuing CA when the root CA and -that CA are available, as with a root the server creates, else self-signed. +that CA are available, as with a root the server creates, else self-signed; it does so also when +the configuration it is given names no source. While HTTPS is on, the Manager's plain HTTP address redirects to its HTTPS address, unless the installer's `https_disable_auto_redirect` or `https.disable_auto_redirect` says otherwise; the status page never redirects. diff --git a/tests/remote/README.md b/tests/remote/README.md index 1d314b4..411ad5d 100644 --- a/tests/remote/README.md +++ b/tests/remote/README.md @@ -62,7 +62,8 @@ The configurations in `configs/` have placeholders that are filled in for each s - `@PSK@`: the pre-shared key, filled in on the Mac; the file reaches the server through the Vault; - `@ETH0@` and `@ETH1@`: the names of its interfaces; -- `@CIDR0@`: the network of its first address. +- `@CIDR0@`: the network of its first address; +- `@FQDN@`: in `dev.json`, the name of the dev VM, `--fqdn` of `lm-dev-vm.py`. ## Secrets @@ -115,7 +116,8 @@ default, such as `LXD_REMOTE`, is required: without its option, the script stops { "LXD_REMOTE": "my-remote", "LXD_POOL": "default", - "LXD_FORWARD_ADDRESS": "192.0.2.10" + "LXD_FORWARD_ADDRESS": "192.0.2.10", + "LXD_DEV_FQDN": "lm-dev.example.org" } ``` @@ -171,6 +173,7 @@ generate it. `remove` deletes the VM, its forward and what the Vault keeps for i | `--config` | | `dev.json` | The configuration from `configs/` | | `--listen` | `LXD_LISTEN` | the remote URL's host | Outside a test project, the address the proxies listen on | | `--forward-address` | `LXD_FORWARD_ADDRESS` | allocated | In a test project, the forward's listen address, one of the uplink's routes, so a recreated VM keeps it | +| `--fqdn` | `LXD_DEV_FQDN` | `lm-dev.test` | The name of the VM, `@FQDN@` of `dev.json`: the Manager and the status web service answer HTTPS for it, so it has to resolve to the forward or proxy address | | `--no-otp` | | off | With `create`, enrol no TOTP token for `admin` | | `--deb` | | the package built last | Outside a test project, the package to install | diff --git a/tests/remote/configs/dev.json b/tests/remote/configs/dev.json index 54c4d1f..c781803 100644 --- a/tests/remote/configs/dev.json +++ b/tests/remote/configs/dev.json @@ -1,5 +1,5 @@ { "general": {"platform": "generic"}, "interfaces": {"external": "@ETH0@"}, - "wan": {"local_fqdn": "lm-dev.test"} + "wan": {"local_fqdn": "@FQDN@"} }