Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Web Key Directory (version 2) #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,38 @@ The HKP APIs are not documented here. Please refer to the [HKP specification](ht

#### Accepted `options` parameters
* mr
* wkd

### Web Key Directory support

Web Key Directory support can be enabled by adding a rewrite rule to web server
configured as a reverse proxy.

Example configuration for caddy webserver (for example.com domain),

```
openpgpkey.example.com {
header /.well-known/openpgpkey/puri.sm/policy Content-Type text/plain
respond /.well-known/openpgpkey/puri.sm/policy `protocol-version 5`
route /.well-known/openpgpkey/example.com/hu/* {
rewrite * /pks/lookup?op=get&{query}%40example.com&options=mr
reverse_proxy localhost:3000
}
}

openpgpkey.example.com DNS records should be pointing to the mailvelope
keyserver instance.
```
#### Usage example with GnuPG

```
gpg --keyserver hkps://keys.mailvelope.com --search info@mailvelope.com
```

If Web Key Directory is enabled,
```
gpg --locate-keys info@mailvelope.com
```
## REST API

### Lookup a key
Expand Down
9 changes: 8 additions & 1 deletion src/route/hkp.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ class HKP {
if (!['get', 'index', 'vindex'].includes(params.op)) {
throw Boom.notImplemented('Method not implemented');
}
this.parseSearch(query.search, params);
let searchString = query.search;
/**
* Search string for Web Key Directory lookups is l
*/
if (query.l) {
searchString = query.l;
}
this.parseSearch(searchString, params);
if (!params.keyId && !params.fingerprint && !params.email) {
throw Boom.badRequest('Invalid search parameter');
}
Expand Down