Gem Version Build Status Test Coverage Maintainability

HKP Client is a minimalist HKP (OpenPGP HTTP Keyserver Protocol) client, which queries PGP public keyservers, and downloads public keys. It does not support submitting keys to keyserver.

This gem registers hkp, and hkps URI schemes (adds them to URI.scheme_list).



Searching by some criteria. Returns search results as an array of arrays.

For exact searches, an exact option can be set to true. The meaning of "exact" is not defined by standard, and may be ignored by servers.

Search operations returns an array of hashes. In this case, it is a one-element array:

        :name=>"Linus Torvalds (Example) <[email protected]>",

Each array item describes a primary key uploaded to keyserver, and is associated with one or more UIDs. For field descriptions, refer to HKP draft, section 5.2.

UID’s name is already percent-decoded. Other values may require parsing or casting (e.g. timestamps and numbers).

Search results may include expired keys. If that’s unwanted, these keys must be filtered out by user.

Fetching keys

Operation returns the ASCII-armored keyring as defined in RFC 2440, section 11.1, or nil.

For example, executing following snippet:

will return string similar to:

Version: SKS 1.1.6
Comment: Hostname:


Arbitrary queries

When above two methods are not flexible enough, a \#query method can be called. It returns an instance of Faraday::Response. All the arguments become query string parameters (with exception of keyserver, which is described in the next section).

For example, a following snippet performs a vindex operation for [email protected] query. The mr option specifies that search results should be presented in a machine-readable format. By default, a human-readable format is used, typically HTML.

HkpClient.query(op: "vindex", search: "[email protected]", options: "mr")

Using custom keyserver

A keyserver option can be passed to either \#search, \#get, or \#query method. Accepted URI schemes are http, https, hkp, and hkps.

TODO: Easy support for custom certificates.

HkpClient.get "[email protected]", keyserver: "hkp://"


First, thank you for contributing! We love pull requests from everyone. By participating in this project, you hereby grant Ribose Inc. the right to grant or transfer an unlimited number of non exclusive licenses or sub-licenses to third parties, under the copyright covering the contribution to use the contribution by all means.

Here are a few technical guidelines to follow:

  1. Open an issue to discuss a new feature prior implementing it.

  2. Write tests for new features or bugfixes.

  3. Make sure the entire test suite passes locally and on CI.

  4. Follow our style guide (you can validate your contribution locally with Rubocop, also Hound CI will report any offences when you open a pull request).


This gem is developed, maintained and funded by Ribose Inc.


The gem is available as open source under the terms of the MIT License.