Skip to content

Instantly share code, notes, and snippets.

@mikaeldui
Last active April 22, 2025 21:39
Show Gist options
  • Save mikaeldui/1968703fc0ba314c4500ea1e6e4351d6 to your computer and use it in GitHub Desktop.
Save mikaeldui/1968703fc0ba314c4500ea1e6e4351d6 to your computer and use it in GitHub Desktop.
Setting up Web Key Directory (WKD) for Proton Mail using Cloudflare Workers

Web Key Directory for Proton Mail using Cloudflare Workers

Web Key Directory is a way for non-Proton users find your keys and encrypt the messages sent to you. Proton doesn't offer this for custom domains out-of-the-box, but you can proxy requests from your domain to Proton.

  1. Create a Cloudflare Worker
  2. Put this code in the Worker:
export default {
  async fetch(request, env, ctx) {
    var url = new URL(request.url);

    if (!url.pathname.startsWith("/.well-known/openpgpkey/"))
      return new Response("Path not found", { status: 404 });    

    url.hostname = "api.protonmail.ch";
    return fetch(url.toString(), request);
  },
};
  1. Save and assign it to openpgpkey.mydomain.com and you're done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment