2026-10-11 10:52:13 +03:00
2026-10-10 22:23:26 +03:00
2026-10-11 10:52:13 +03:00
2026-10-11 10:52:13 +03:00
2026-10-11 10:52:13 +03:00
2026-10-11 10:52:13 +03:00
2026-10-11 10:52:13 +03:00
2026-10-10 22:30:42 +03:00
2026-10-11 10:52:13 +03:00

OpenPGP Key Distribution: WKD + HKP + VKS

This project combines an Nginx frontend with a Hagrid backend.

  • WKD: static files under /.well-known/openpgpkey/.
  • HKP: /pks/lookup and /pks/add, handled by Hagrid.
  • VKS: /vks/v1/ API, handled by Hagrid.
  • Static downloads: optional public-key files under /keys/.

Hagrid supports a subset of HKP and its native VKS API. It is not full SKS/HKP feature parity. See https://keys.openpgp.org/about/api/

Important deployment caveat

The Compose file uses the community-maintained jumper78/hagrid-openpgp image as an example, not an official production image published by keys.openpgp.org. Confirm its current image tag, internal listen port, persistent-data path, and configuration requirements before deploying. The sample assumes port 8000 and /data; change these to match the selected image. The scaffold does not configure TLS, DNS, or SMTP automatically.

Start

  1. Copy .env.example to .env.
  2. Review the Hagrid image's documentation and verify port and volume settings.
  3. Run:
docker compose up -d --build
docker compose ps
docker compose logs -f

Frontend: http://localhost:8088. /healthz returns OK. Use HTTPS in production by placing this behind a trusted TLS reverse proxy.

HKP

Lookup a key:

curl -i 'http://localhost:8088/pks/lookup?op=get&search=user%40example.com'

GnuPG lookup:

gpg --keyserver hkp://localhost:8088 --search-keys FINGERPRINT

Submit an ASCII-armored public key:

gpg --armor --export user@example.com > publickey.asc
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode keytext@publickey.asc http://localhost:8088/pks/add

HKP upload does not verify email ownership. Use VKS for the verification workflow.

VKS

Fetch by uppercase fingerprint (without 0x):

curl -i 'http://localhost:8088/vks/v1/by-fingerprint/UPPERCASE_FINGERPRINT'

Fetch by key ID:

curl -i 'http://localhost:8088/vks/v1/by-keyid/UPPERCASE_KEY_ID'

Fetch by URL-encoded email (only published/verified addresses are discoverable):

curl -i 'http://localhost:8088/vks/v1/by-email/user%40example.com'

Upload a public key:

gpg --armor --export user@example.com > publickey.asc
python3 -c 'import json,pathlib; print(json.dumps({"keytext":pathlib.Path("publickey.asc").read_text()}))' > upload.json
curl -i -H 'Content-Type: application/json' --data-binary @upload.json http://localhost:8088/vks/v1/upload

The owner may need to complete an email-verification step before email lookup works. Configure SMTP as documented by the selected Hagrid image if using verification emails.

WKD

The direct-method URL usually has this form:

https://example.com/.well-known/openpgpkey/hu/<z-base-32-hash>

Use GnuPG to display the correct WKD hash:

gpg --with-wkd-hash --list-keys user@example.com

Place the binary public-key export at the matching path beneath wkd/, for example wkd/example.com/hu/<hash>. WKD must be served from the correct email domain over HTTPS; a keys.example.com hostname does not automatically enable WKD for example.com.

Static downloadable key example:

gpg --armor --export user@example.com > keys/user@example.com.asc
curl -f http://localhost:8088/keys/user@example.com.asc

Security

  • Never publish private/secret keys.
  • Use HTTPS in production and verify fingerprints via a separate trusted channel.
  • Review and pin the Hagrid image rather than blindly using latest.
  • Back up Hagrid's persistent data and keys/ / wkd/.
  • Monitor logs, rate limits and email verification; configure SMTP if required.
  • This sample has not been tested against your actual image, reverse proxy, DNS or mail setup.

Troubleshooting

  • 502: Hagrid may not be running or may use a different port; update nginx.conf.
  • 404 VKS email lookup: the key may be absent or the address not verified/published.
  • WKD failure: check the HTTPS origin, hash, domain-specific path and binary key format.

References

S
Description
No description provided
Readme
37 KiB
Languages
Shell 84.1%
Dockerfile 15.9%