- Profiler: server_files_missing/require_* helpers; 409 for /server/configure, start/restart and POST /profiles when the PKI is not initialized or server files (honouring fqdn_server) are missing; stop stays allowed; DELETE /system/pki returns 409 while OpenVPN runs; GET /system/init/status adds pki_ready, server_ready, missing. - UI: shared usePkiStatus; VPN menu item locked until the PKI is ready, route guard for /config/vpn, Start/Restart and New Client disabled with hints, lock notice on the VPN page. - Test: one pytest (test_pki_guard.py). - Docs: plan and summary in DOCS/Changes, API reference, README, Index. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3.1 KiB
3.1 KiB
PKI dependency guard (2026-10-04)
Goal: while the PKI is not initialized the VPN (server) section is closed, and nothing that needs keys can run. Plan: PKI_Dependency_Guard_PLAN.
Rules (backend is the source of truth)
| Operation | Rule |
|---|---|
POST /server/configure, POST /server/process/start, restart |
409 unless the PKI is initialized, no init job runs and every file server.conf points to exists (ca.crt, issued/<fqdn_server>.crt, private/<fqdn_server>.key, dh.pem, ta.key, crl.pem when crl_verify is on). The message names the missing files, so a changed fqdn_server is caught too |
POST /server/process/stop |
always allowed |
POST /profiles |
409 unless the PKI is initialized and no init job runs |
DELETE /system/pki |
409 while an init job runs and 409 "Stop OpenVPN first" while OpenVPN runs |
PUT /config/server, GET /config, monitoring |
open (no key operation) |
GET /system/init/status |
new fields pki_ready, server_ready, missing |
UI
| Area | Change |
|---|---|
composables/usePkiStatus.js |
Shared status, refreshed on login, on every route change and by the PKI page (init finished, Clear PKI) |
Sidebar (App.vue) |
VPN item is locked (lock icon, muted, tooltip "Initialize PKI first") until the PKI is ready; a click goes to the PKI page |
Router (router/index.js) |
/config/vpn requires a ready PKI; otherwise redirect to the PKI page with a toast (also for a typed URL). A failed status request does not block navigation |
ServerManagement.vue |
Start / Restart disabled with a hint (missing files); Stop stays enabled |
Certificates.vue |
New Client disabled with a hint |
VPNConfig.vue |
Lock notice with a link to the PKI page instead of the form when the PKI is not ready; backend error text in toasts |
Verification (containers)
| Check | Result |
|---|---|
pytest (test_pki_guard, test_async_pki_init, test_profile_note) in python:3.12-alpine |
3 passed |
| After Clear PKI: status | pki_ready: false, server_ready: false, missing files listed |
| After Clear PKI: configure, start, restart, create client | 409; stop 200 |
| Init PKI, then configure, start | 200, 200 |
| Clear PKI while OpenVPN runs | 409 Stop OpenVPN first |
fqdn_server renamed after init: configure, start |
409, names issued/renamed-srv.crt and private/renamed-srv.key |
| Create a client after init | 200 |
| UI bundle contains the guard texts | yes; behaviour in the browser is checked manually |
Notes
- The status is refreshed on navigation and by the PKI page, not by polling: an open VPN page notices a cleared PKI on its next refresh (navigation or a failed Apply).
- After a rename of
fqdn_serverthe VPN page stays reachable (the PKI itself is intact); configure, start and restart are blocked and name the missing certificate. DELETE /system/pkitakes about a second longer while OpenVPN runs (process statistics).
Existing installations
No manual steps. Rebuild and restart the Profiler and the UI. A running server is not affected until it is restarted.