GPG Public Key Server with Web Key Directory (WKD)
A small Docker/Nginx service that publishes OpenPGP public keys as static files. It supports the WKD direct method as well as optional human-downloadable armored keys. WKD lets compatible OpenPGP clients discover a public key from an email address and its domain.
This is a static WKD publisher, not a full HKP/HKPS keyserver or a key-submission service. It does not automatically verify ownership of email addresses or update/revoke published keys.
Files
gpg-keyserver-wkd/
├── Dockerfile
├── docker-compose.yml
├── nginx.conf
├── publish-wkd-key.sh
├── README.md
├── keys/ # Optional ASCII-armored downloads
└── wkd/
├── policy # WKD policy marker (created by script)
└── hu/ # Binary public keys named by WKD hash
Requirements
- Docker Engine and Docker Compose v2
- GnuPG installed on the host for key export
- A domain you control and HTTPS for production
Start the container
From this directory:
docker compose up -d --build
docker compose ps
curl -f http://localhost:8088/healthz
Expected health response: OK. The service is available locally on port 8088.
Publish a WKD key
First ensure the public key for the target email address is in your local GPG keyring. Export public keys only; never export secret/private keys to this service.
On Linux, macOS, or WSL, run from this project directory:
./publish-wkd-key.sh user@example.com
The script uses gpg-wks-client --print-wkd-hash to compute the WKD filename, exports a binary public key into wkd/hu/<hash>, creates the wkd/policy marker, and exports an optional ASCII-armored copy into keys/user@example.com.asc.
The Docker container mounts wkd/ and keys/ read-only. Files added or updated on the host are served without rebuilding the image.
Manual export (if you prefer)
HASH="$(gpg-wks-client --print-wkd-hash user@example.com | awk 'NR==1 {print $1}')"
mkdir -p wkd/hu
: > wkd/policy
gpg --batch --export user@example.com > "wkd/hu/$HASH"
The WKD object should be a binary OpenPGP export. The public key must contain the intended email address in a user ID, and you should verify its fingerprint independently before publishing.
URL layout and DNS/HTTPS
This configuration implements the direct method. For user@example.com, the path is:
https://example.com/.well-known/openpgpkey/hu/<WKD_HASH>?l=user
The policy marker must be available at:
https://example.com/.well-known/openpgpkey/policy
Replace example.com with your actual email domain. The Nginx container itself only speaks HTTP on port 80; put it behind your existing HTTPS reverse proxy and route the domain's requests to this service. The certificate must be valid for the email domain. WKD requires HTTPS; do not treat plain HTTP testing as production validation.
For the direct method, the email domain itself must serve /.well-known/openpgpkey/. If your main website already owns that domain, configure its reverse proxy to route that path to this service, or merge the WKD files and Nginx location into the existing web server. Do not simply point the whole domain at this container if that would replace your existing website.
The alternative advanced method uses https://openpgpkey.example.com/.well-known/openpgpkey/example.com/... and requires a dedicated openpgpkey subdomain with HTTPS. This sample is configured for the direct method only.
Test WKD
After configuring DNS and HTTPS, use GnuPG from a client machine:
gpg --locate-keys --auto-key-locate clear,nodefault,wkd user@example.com
You can also check the raw key URL locally after publishing. Substitute the hash printed by the script:
curl -f http://localhost:8088/.well-known/openpgpkey/hu/<WKD_HASH>
A successful local HTTP request verifies file serving only; final validation must use the public HTTPS URL and your real email domain.
Security and maintenance
- Never put private keys, secret-key exports, passwords, or private key backups in
keys/orwkd/. - Public keys are public, but their association with an email address should be verified before publication.
- Directory listing is disabled; only GET and HEAD are allowed for key paths.
- WKD does not itself prove a key is safe or current. Publish updates and revocations when appropriate, and verify fingerprints through a separate trusted channel.
- The sample grants
Access-Control-Allow-Origin: *only for WKD paths because browser-based clients may need cross-origin reads. - Keep the reverse proxy and TLS certificates correctly configured and renewed.
Useful commands
docker compose logs -f gpg-keyserver
docker compose restart
docker compose down
docker compose up -d --build