feat(gpg): serve the current key and publish it via WKD #5

Merged
magndotcc merged 1 commit from feat/gpg-key-publication into main 2026-09-27 20:04:05 +00:00
Owner

GPT-6 Astra in Pi responding on behalf of Magnus

what this changes

The public key the site served was missing the encryption subkey, so anyone sending an encrypted mail to [email protected] got no valid OpenPGP data found. This refreshes static/gpg.asc with the current export, which adds the cv25519 encryption subkey.

The key is now reachable from a few more paths so it is easier to find by hand:

/gpg.asc  /gpg  /gpg.txt  /pgp  /pgp.asc  /key  /key.asc

/gpg.asc still works so existing links keep resolving. The about page now points at /pgp.

The contact email on the about page moves from [email protected] to [email protected], which is the address the key actually carries and one less thing to explain.

Web Key Directory support, so mail clients can fetch the key from the domain directly with no lookup step and no keyserver trust.

how WKD is wired up

gpg --locate-keys [email protected] builds a path from the SHA-1 of the local part, z-base-32 encoded. That value is computed in the worker from the address list rather than written out, so adding an address is a one-line change:

[email protected]  ->  s8y7oh5xrdpu9psba3i5ntk64ohouhga

The spec asks for the binary key and the repo keeps it armored so it stays readable and diffable, so the handler converts it on the way out. Output is byte-for-byte identical to gpg --dearmor. The policy file is served too, since the spec requires it even without the update protocol.

The handler only answers for addresses listed in WKD_ADDRESSES and rejects a mismatched domain on the advanced path, so it cannot be used to serve keys for a domain we don't speak for.

testing

Ran the worker locally and hit every path:

  • all seven armored paths return application/pgp-keys, 1449 bytes
  • both WKD methods return application/octet-stream, 1009 bytes, byte-identical to gpg --dearmor
  • importing the served binary into a clean keyring yields the primary, both signing subkeys, and the encryption subkey
  • policy returns 200 with zero length on both methods
  • wrong domain, unknown hash, and junk paths all 404
  • /, /about, /projects, /rss, /md, /md/about, and a post all still 200
  • tsc --noEmit clean

blocker that is not in this PR

magn.cc 301-redirects to mageick.me for every path except two, so requests for the WKD path never reach the worker.

A Worker route was added for magn.cc/.well-known/openpgpkey/* pointing at mageick-me-blog, and it does not take effect: the path still returns 301. The existing magn.cc/.well-known/matrix/* route works, but only because the redirect rule has exact-path exceptions rather than a prefix one:

/.well-known/matrix/server      -> 200 (exception)
/.well-known/matrix/client      -> 200 (exception)
/.well-known/matrix/other       -> 301 (no exception)
/.well-known/matrix/server/deep -> 301 (exact match only)

Worker routes therefore do not run before the redirect on this zone, and a prefix match is not enough. Two ways to fix, both needing dashboard access the deploy token does not have:

  1. Add the policy and hu/<hash> paths as exact exceptions, mirroring how matrix is done.
  2. Replace the redirect with the worker doing it, then attach magn.cc as a custom domain to mageick-me-blog.

Option 2 keeps the exception in code. Until one lands, WKD for [email protected] hits a redirect and fails.

GPT-6 Astra in Pi responding on behalf of Magnus ## what this changes The public key the site served was missing the encryption subkey, so anyone sending an encrypted mail to `[email protected]` got `no valid OpenPGP data found`. This refreshes `static/gpg.asc` with the current export, which adds the `cv25519` encryption subkey. The key is now reachable from a few more paths so it is easier to find by hand: ``` /gpg.asc /gpg /gpg.txt /pgp /pgp.asc /key /key.asc ``` `/gpg.asc` still works so existing links keep resolving. The about page now points at `/pgp`. The contact email on the about page moves from `[email protected]` to `[email protected]`, which is the address the key actually carries and one less thing to explain. Web Key Directory support, so mail clients can fetch the key from the domain directly with no lookup step and no keyserver trust. ## how WKD is wired up `gpg --locate-keys [email protected]` builds a path from the SHA-1 of the local part, z-base-32 encoded. That value is computed in the worker from the address list rather than written out, so adding an address is a one-line change: ``` [email protected] -> s8y7oh5xrdpu9psba3i5ntk64ohouhga ``` The spec asks for the binary key and the repo keeps it armored so it stays readable and diffable, so the handler converts it on the way out. Output is byte-for-byte identical to `gpg --dearmor`. The `policy` file is served too, since the spec requires it even without the update protocol. The handler only answers for addresses listed in `WKD_ADDRESSES` and rejects a mismatched domain on the advanced path, so it cannot be used to serve keys for a domain we don't speak for. ## testing Ran the worker locally and hit every path: - all seven armored paths return `application/pgp-keys`, 1449 bytes - both WKD methods return `application/octet-stream`, 1009 bytes, byte-identical to `gpg --dearmor` - importing the served binary into a clean keyring yields the primary, both signing subkeys, and the encryption subkey - `policy` returns 200 with zero length on both methods - wrong domain, unknown hash, and junk paths all 404 - `/`, `/about`, `/projects`, `/rss`, `/md`, `/md/about`, and a post all still 200 - `tsc --noEmit` clean ## blocker that is not in this PR `magn.cc` 301-redirects to `mageick.me` for every path except two, so requests for the WKD path never reach the worker. A Worker route was added for `magn.cc/.well-known/openpgpkey/*` pointing at `mageick-me-blog`, and it does not take effect: the path still returns 301. The existing `magn.cc/.well-known/matrix/*` route works, but only because the redirect rule has exact-path exceptions rather than a prefix one: ``` /.well-known/matrix/server -> 200 (exception) /.well-known/matrix/client -> 200 (exception) /.well-known/matrix/other -> 301 (no exception) /.well-known/matrix/server/deep -> 301 (exact match only) ``` Worker routes therefore do not run before the redirect on this zone, and a prefix match is not enough. Two ways to fix, both needing dashboard access the deploy token does not have: 1. Add the `policy` and `hu/<hash>` paths as exact exceptions, mirroring how matrix is done. 2. Replace the redirect with the worker doing it, then attach `magn.cc` as a custom domain to `mageick-me-blog`. Option 2 keeps the exception in code. Until one lands, WKD for `[email protected]` hits a redirect and fails.
The key on the site was missing the encryption subkey, so anyone
encrypting to [email protected] failed with "no valid OpenPGP data found". Refresh
static/gpg.asc with the current export, which includes the cv25519
encryption subkey.

Serve the key from a few more paths so it is easy to find by hand, and add
a Web Key Directory so mail clients can fetch it from the domain on their
own. The WKD handler only answers for addresses listed in WKD_ADDRESSES and
returns the binary form the spec asks for, converted from the armored file
in the repo.
magndotcc force-pushed feat/gpg-key-publication from a74e037b79 to 3e9181744c 2026-09-27 19:58:10 +00:00 Compare
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
magndotcc/blog!5
No description provided.