System integration
This page covers how testd integrates with your OS and network stack: port 443, .test DNS, local PKI, external reverse proxies, CI automation, and clean removal.
Privileged ports
- Linux: binding port
443requiresCAP_NET_BIND_SERVICE, root, or a high port:- System service (recommended for headless CLI):
packaging/systemd/[email protected]runs as your user with onlyCAP_NET_BIND_SERVICE. - Foreground CLI:
sudo setcap 'cap_net_bind_service=+ep' "$(readlink -f "$(command -v testd)")"(re-run after replacing the binary). - Desktop app:
sudo setcap 'cap_net_bind_service=+ep' /path/to/testd-guion the actual tray binary (not an AppImage wrapper). - High port: set
[host] edge_addr = '127.0.0.1:8443'in~/.config/testd/config.tomland openhttps://app.example.test:8443. - User service:
packaging/systemd/testd.servicesetsNoNewPrivileges=yes, so it cannot use file capabilities; pair it with a high port.
- System service (recommended for headless CLI):
- macOS: if binding
127.0.0.1:443is denied, testd asks the logged-in user'slaunchdGUI session for that exact loopback socket, then unloads the temporary socket-transfer job before startup finishes. Both the daemon and tray stay unprivileged. A logged-in desktop session is required for this fallback; headless environments can use a high port or the launchd template inpackaging/launchd/dev.testd.host.plist. - Windows: no extra capability is needed beyond approving the normal firewall prompt.
DNS resolution
testd runs a built-in DNS server on loopback (127.0.0.1:7753 on Linux/macOS, 127.0.0.1:53 on Windows).
- On Linux, setup reuses a compatible existing global
.testroute without adopting it, and reports conflicting global settings or per-link routes rather than overwriting them. - On macOS, setup writes a
.testresolver file pointing to127.0.0.1:7753. - On Windows, setup configures an NRPT rule routing
.testto127.0.0.1:53.
Certificates and PKI
testd manages a three-tier local PKI under ~/.config/testd/pki/ (or %APPDATA%\testd\pki\ on Windows):
- Root CA (
root.crt/root.key): 10-year lifetime; installed once in your system trust store. - Host intermediate (
node.crt/node.key): 1-year lifetime; renews automatically near expiry on startup or certificate minting without changing root trust. Previous intermediates are backed up inpki/backups/. - Leaf certificates: 24-hour lifetime; minted on demand in memory for each live name.
testd doctor reports upcoming expiry and testd doctor --fix repairs the PKI if root.key is present. (If you moved root.key offline, bring it back before the intermediate expires.)
The dashboard's Certificate card shows trust status, SHA-256 fingerprint, expiry, and install/remove buttons (plus a separate Firefox trust check when viewed in Firefox). Anyone on the host can download the public root certificate with:
curl http://127.0.0.1:7737/ca.crt -o testd-root.crtKeep pki/root.key strictly on the host. If it is ever exposed, rebuild the PKI, reinstall trust on every browser machine, and restart the host.
External front
The built-in HTTPS edge works out of the box and does not require Caddy or nginx. If you already run an external reverse proxy on port 443, you can wire testd behind it:
[host]
# Move the built-in HTTPS edge off 443, or disable it with edge_enabled = false.
edge_addr = '127.0.0.1:8443'
# Plain HTTP routing listener used by external fronts (always runs).
http_addr = '127.0.0.1:7740'
# Only enable when a front you control sets and strips X-Forwarded-For.
trust_forwarded_for = false- Set
edge_enabled = falsewhen an external front owns port443, or keepedge_enabled = trueand moveedge_addrto another port to run both side by side. - If your external front runs in a container or another network namespace, bind
http_addrto an address it can reach. - For Caddy users:
testd initdetects Caddy and offers to add the import line to your global Caddyfile. You can also runtestd export-caddyfileto generate the managed Caddyfile and print theimportline, andtestd doctor --fixto verify the import and reload Caddy. - With
edge_enabled = false, browsers trust your external front's CA (such as Caddy's internal CA) rather than the testd root.testd doctorstill checks testd's PKI because remote registration TLS needs it. - Keep
trust_forwarded_for = falseunless a front you control setsX-Forwarded-For; otherwise clients can spoof their source IP. On the plain listener,testd.testis only served whentrust_forwarded_for = trueand the first forwarded hop is loopback.
Automation
For non-interactive scripts or CI, supply a credential so testd run does not pause for approval:
export TESTD_TOKEN="$(cat /run/secrets/testd-token)"
testd run --host 192.168.1.5 --token-profile ci app.example:3000 -- ./serverPrefer an issued token (scoped and revocable) over the operator secret. A credential file under ~/.config/testd/credentials/<profile> also works if you want to avoid putting the token in an environment variable (which is visible to same-user process inspection on most OSes).
testd run exits with the child process's exit code (and stops the child if registration fails). Use testd doctor --json for structured health checks in scripts.
Design notes
Why testd is built the way it is:
- One host is the authority: DNS, TLS, tokens, and approvals live on the browser machine. No central server, accounts, mesh, or public DNS.
- The connection is the lease: A claim exists only while its TCP connection is open, so crashes and network drops clean up automatically.
- Tokens are durable, grants are exact: You approve a leaf once per name instead of on every run, and can revoke individual names or whole tokens later.
- Encrypted over the network: Remote registration uses NDJSON over pinned TLS 1.3; remote app forwarding uses mutual TLS. Local-only registrations keep a simple loopback protocol.
- Local CA, short-lived leaves: Trust one local root once, and get automatic HTTPS for every project without per-project cert files.
Clean up and uninstall
On Windows, exit Testd from the tray and stop any CLI host or service, then open Settings > Apps > Installed apps > Testd > Uninstall. The uninstaller defaults to Remove owned .test DNS rules and trusted roots, requests UAC approval, and completes ownership-checked system cleanup before deleting the app. Also permanently delete this user's Testd profile is separate and unchecked by default. It deletes %APPDATA%\testd, including its local CA and tokens, only after successful system cleanup; an external custom PKI directory is kept.
Cancelling before cleanup makes no changes. Denying UAC or encountering missing ownership evidence, changed integration, or a system-cleanup failure stops app removal and keeps profile data and recovery records for retry. Fix the reported problem and rerun the uninstaller. Keep DNS rules and trusted roots for a reinstall removes the app while keeping system integration and profile data. The uninstaller preserves an unrelated testd:// handler and unrelated files in the installation directory. It removes the handler and login entry only when their commands still match this installation.
Windows upgrades call the uninstaller with /P /UPDATE and retain system integration, profile data, and the login entry. Older callers using /P have the same retention behavior. Standalone /S calls are silent and retain system integration and profile data; they remove an unchanged handler and login entry. None of these unattended modes invokes the privileged cleanup helper or purges the profile. Exit the tray before replacement or removal; a running tray stops uninstall with exit code 2. Automated system cleanup remains available through the CLI command before an unattended app removal.
On Linux and macOS, removing the desktop package leaves the DNS route and trusted root installed. For those platforms, or for a Windows CLI installation:
- Stop any running quick launches, SSH apps, and shares. If you use the desktop app, untick Launch at login and click Exit in the tray menu (or stop
testd host/ your system service). - Remove system integration:
testd uninstall # removes owned DNS resolver route and root trust; keeps local config/data
testd uninstall --purge # also deletes the config directory after system cleanup succeeds- Remove the installed binaries or desktop package (drag
Testd.appto Trash, remove the.deb/.AppImage, run the Windows uninstaller, or deletetestdfrom~/.local/bin).
Key safety guarantees across Linux, macOS, and Windows:
- Ownership verified first:
uninstallonly removes resolver rules and root certificates that belong to this installation and have not been modified externally. Unowned or changed system state is left untouched and reported as a conflict. - Missing root certificate: if
pki/root.crtis missing, trust removal and--purgewill not complete; restore the certificate first. - Custom PKI paths:
--purgedeletes the config directory (including the default PKI and tokens), but does not delete a custompki_diroutside it. - Windows ownership records: Windows verifies the private installation ID and administrator-owned NRPT and root-store records before removing anything, leaving backups in
%ProgramData%/testd/ownership/history. - Binaries stay put:
testd uninstallcleans up system integration and optional config data; it does not delete thetestdbinary or desktop app.