vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Serve HTTPS on macOS with socket activation
54ccf66e63032dd8e5afd80f609d6e6be183e5f5 · Keenan Nemetz · 3d ago · parent 75478a9d
Serve HTTPS on macOS with socket activation Let vole serve accept listeners the service manager already owns, so a launchd LaunchDaemon can own ports 80/443 as root and hand the ready sockets to an unprivileged serve for ACME. Reads LISTEN_FDS/LISTEN_PID (and launchd's Listeners), defaults the platform contract to the host, and falls back to binding http_addr/https_addr when no descriptors are inherited. Add unit tests for the env contract and fd wrapping, plus an integration test that execs the real binary with an inherited fd and completes a request. Document the socket-activation choice in the macOS deploy guide.
docs/deploy/macos.md +39
| @@ -143,6 +143,45 @@ sudo launchctl kickstart -k system/software.rodent.vole | |||
| 143 | 143 | ||
| 144 | 144 | Stop and unload with `sudo launchctl bootout system/software.rodent.vole`. | |
| 145 | 145 | ||
| 146 | ## Serve HTTPS with socket activation | ||
| 147 | |||
| 148 | ACME needs port 80 (HTTP-01) or 443 (TLS-ALPN-01), and macOS refuses ports below | ||
| 149 | 1024 to a non-root process. The answer is **socket activation**: a LaunchDaemon | ||
| 150 | owns 80 and 443 as root and hands the ready sockets to `vole serve`, which keeps | ||
| 151 | running unprivileged. The same mechanism is systemd's `LISTEN_FDS`, so one code | ||
| 152 | path serves both operating systems. | ||
| 153 | |||
| 154 | `serve` reads `LISTEN_FDS`/`LISTEN_PID` (and launchd's `Listeners`) at startup. | ||
| 155 | When inherited descriptors are present it serves HTTP and HTTPS from them instead | ||
| 156 | of binding `http_addr`/`https_addr`; when they are absent it binds exactly as a | ||
| 157 | hand-run or containerized instance always has. The ACME cache, challenge handler, | ||
| 158 | and certificate manager do not care which descriptor is underneath them. | ||
| 159 | |||
| 160 | Install the daemon that owns the sockets. `share/launchd/software.rodent.vole.plist` | ||
| 161 | in the tap is a `Sockets` block for 80 and 443; copy it to | ||
| 162 | `/Library/LaunchDaemons/`, set the `_vole` account, and load it: | ||
| 163 | |||
| 164 | ```sh | ||
| 165 | sudo cp software.rodent.vole.plist /Library/LaunchDaemons/ | ||
| 166 | sudo launchctl bootstrap system /Library/LaunchDaemons/software.rodent.vole.plist | ||
| 167 | ``` | ||
| 168 | |||
| 169 | With it loaded, `vole.toml` names the privileged ports and the daemon delivers | ||
| 170 | them: | ||
| 171 | |||
| 172 | ```toml | ||
| 173 | http_addr = ":80" | ||
| 174 | https_addr = ":443" | ||
| 175 | acme_email = "admin@example.com" | ||
| 176 | acme_domains = ["forge.example.com"] | ||
| 177 | ``` | ||
| 178 | |||
| 179 | `vole serve` never runs as root. A LaunchAgent cannot own a privileged socket, so | ||
| 180 | `brew services` keeps serving the unprivileged loopback addresses; the daemon is | ||
| 181 | the HTTPS path. The trade-offs that chose this arrangement over running as root or | ||
| 182 | putting a terminator proxy in front are the three options worth naming: root gives | ||
| 183 | up the unprivileged property, and a proxy contradicts one binary to operate. | ||
| 184 | |||
| 146 | 185 | ## What launchd does not give you | |
| 147 | 186 | ||
| 148 | 187 | The Linux package hardens `vole.service` with systemd's sandboxing: | |