skip to content

How does an OpenPGP sender find a new correspondent's key through Web Key Directory, OPENPGPKEY records or a keyserver, and what does each prove?

level: middleimportance: should knowfreq 16%

answer

  1. who published it, and over what
  2. HTTPS under the mail domain
  3. advanced before direct method
  4. DNSSEC Secure or nothing
  5. keyservers accept anyone's upload

basics

~20 s

Web Key Directory fetches the key over HTTPS from the recipient's mail domain; OPENPGPKEY fetches it from a DNSSEC-signed zone; a public keyserver returns whatever anyone uploaded. The first two mean the domain published it; a keyserver result proves nothing.

solid answer

~40 s

OpenPGP messages need not carry the sender's key, so a sender often has to look it up. **Web Key Directory**, an individual Internet-Draft (`draft-koch-openpgp-webkey-service-22`, July 2026), hashes the lowercased local part with SHA-1, encodes it in z-base-32 and fetches `https://openpgpkey.example.org/.well-known/openpgpkey/example.org/hu/<hash>` first, falling back to the direct form under `https://example.org/.well-known/openpgpkey/hu/` only when the `openpgpkey` subdomain does not exist. **OPENPGPKEY** (RFC 7929, Experimental) puts the key in DNS under a truncated SHA2-256 hash and `_openpgpkey`, and the answer MUST pass DNSSEC validation. A **public keyserver** accepts uploads naming any address and cannot confirm ownership. S/MIME instead finds certificates in signed mail or a directory.

code

pseudocode · 15 lines
pseudocode
function findKey(address):
    local, domain = split(address)
    hu = zbase32(sha1(lowercaseAscii(local)))
    if hasAddress("openpgpkey." + domain):             # advanced method
        key = httpsGet("https://openpgpkey." + domain + "/.well-known/openpgpkey/"
                       + lower(domain) + "/hu/" + hu + "?l=" + local)
    else:                                               # direct method
        key = httpsGet("https://" + domain + "/.well-known/openpgpkey/hu/"
                       + hu + "?l=" + local)
    if key and hasUserId(key, address):
        return keepOnlyUserId(key, address)          # published by the domain
    rr = dnsQuery(sha256hex28(local) + "._openpgpkey." + domain, OPENPGPKEY)
    if rr and rr.dnssec == "Secure":
        return rr.key                                # published in a signed zone
    return none   # a keyserver hit is only a candidate until its fingerprint is checked

go deeper

for a junior

Recall the three sources and who stands behind each: the recipient's mail domain over HTTPS, the recipient's signed DNS zone, or anyone at all on a public keyserver.

for a middle

Explain how the Web Key Directory URL is built, the advanced-before-direct rule, the DNSSEC requirement for OPENPGPKEY, and why a keyserver hit still needs a fingerprint check.

for a senior

Show you can run publication for a domain: strip extra User IDs, serve the policy file, avoid wildcard DNS swallowing the openpgpkey subdomain, and know which sources are drafts or experimental.

for a principal

Decide where your organisation publishes keys and what correspondents are told to trust, weighing a web server you control against DNS you may not, and draft status against reach.

## The discovery problem To encrypt to someone for the first time, a sender needs their public key. NIST SP 800-177 Rev. 1 notes that OpenPGP does not always include the sender's key with each message, so recipients and repliers often have to fetch it separately. S/MIME clients usually harvest a certificate from a correspondent's signed mail or query a directory; that side is covered with S/MIME certificate discovery. OpenPGP has three common sources, and they differ mainly in **who published the key** and therefore what a successful lookup means. ## Public keyservers - A keyserver keeps a database of keys searchable by address, and anyone may upload a key carrying any address. - The Web Key Directory draft points out that keyservers cannot confirm that a key belongs to the address in it, and that several keys often match one address, leaving the sender to "pick a key on good luck". - NIST puts it plainly: there are no access controls, and validating a downloaded key is the downloader's job. A keyserver result is therefore only a candidate, to be confirmed by a fingerprint check or by certifications the receiver trusts. ## Web Key Directory **Web Key Directory (WKD)** is specified in `draft-koch-openpgp-webkey-service-22` (22 July 2026), an individual Internet-Draft with intended status Informational. It is not an RFC. The client builds a URL from the address: 1. Map ASCII upper-case letters in the local part to lower case and hash it with **SHA-1**. 2. Encode the 160-bit digest in **z-base-32**, giving a fixed 32-character string. 3. Try the **advanced method** first: `https://openpgpkey.` plus the domain, then `/.well-known/openpgpkey/`, the lower-case domain, `/hu/`, the hash, and the original local part as the `l` parameter. 4. Fall back to the **direct method**, `https://` plus the domain and `/.well-known/openpgpkey/hu/` plus the hash, only if the `openpgpkey` subdomain has no address. A server that does not respond is not a reason to fall back. ``` https://openpgpkey.example.org/.well-known/openpgpkey/example.org/hu/iy9q...n5q?l=Joe.Doe https://example.org/.well-known/openpgpkey/hu/iy9q...n5q?l=Joe.Doe ``` The draft also sets duties on both sides: - The server returns the binary key, which must carry a User ID with the requested address; the provider MUST strip every other User ID before publication. - The client MUST check that the requested User ID is present and MUST drop all others. - The server MUST serve a policy flags file, and a client MUST NOT accept an HTTP authentication challenge. - The SHA-1 step is not a security feature; it only maps the local part to a file-safe string and does not conceal the address. What a WKD hit proves is that whoever runs HTTPS for the mail domain published that key. NIST describes posting keys on TLS-protected websites as using the X.509 infrastructure to certify OpenPGP keys. ## OPENPGPKEY records RFC 7929 (August 2016, **Experimental**) publishes a key in DNS. The local part is hashed with SHA2-256, truncated to 28 octets and written in hex as the left-most label, followed by `_openpgpkey` and the domain. The DNS answer MUST pass DNSSEC validation; any state other than Secure is a failure. RFC 7929 also asks clients to remember failed lookups and not to query at every use, because each query is a privacy leak. The WKD draft adds two practical objections: small mail installations often do not control their DNS, and DNS lookups are unencrypted, so they reveal which local part is being looked up. ## Comparing the sources | Source | Published by | What a hit shows | Status | |---|---|---|---| | Public keyserver | Anyone | Nothing about ownership | Practice | | Web Key Directory | The mail domain's HTTPS server | The domain published this key | Individual Internet-Draft | | OPENPGPKEY | The mail domain's signed zone | The domain published this key | RFC 7929, Experimental | | S/MIME discovery | Signed mail or a directory | A certificate to validate against trust anchors | Covered with S/MIME discovery | ## Choosing for a domain you run - Publishing through WKD needs only a web server; the direct method needs no DNS change at all. - OPENPGPKEY suits a domain that already signs its zone and wants keys beside its other DNS data. - Keyservers can stay as a convenience, but correspondents should be told to confirm fingerprints for anything fetched there.

  • Why does the Web Key Directory draft forbid falling back to the direct method when the advanced server does not respond?
    The fallback exists for domains that never created the openpgpkey subdomain. If the subdomain exists but its server is down, the domain has chosen the advanced method, and querying the bare domain instead could return a stale or different key from a server the domain did not intend to use for key publication.
  • What does a Web Key Directory provider have to remove before publishing a user's key?
    Every User ID other than the one with the address being published, together with its binding signatures. The client also MUST drop any other User IDs it receives, so a key fetched for [email protected] cannot smuggle in claims about other addresses.
  • How does an S/MIME client usually obtain a new correspondent's certificate instead?
    Most often from a signed message the correspondent sent, since RFC 8550 says senders SHOULD include their certificates, or from an organisational directory. How those certificates are found and trusted is covered with S/MIME certificate discovery.

  • A key found on a public keyserver for an address belongs to that address.
  • Web Key Directory hashes the local part with SHA-1 to hide the address.
  • Web Key Directory and OPENPGPKEY are both published RFCs on the standards track.
  • An OPENPGPKEY answer is usable without DNSSEC if the key's self-signature verifies.
  • If the advanced WKD server times out, the client should try the direct method.