CH-J Toolsserver management over SSH
Menu
All guides and articles →

How to search for OpenPGP keys using the API

Reading VKS and HKP queries, fingerprint, email encoding, HTTP statuses and checking the downloaded certificate in the application.

If you know a trusted fingerprint, use it

API lookups are supposed to find a public certificate, which you then verify and use. The most reliable identification for a targeted query is a full, pre-verified fingerprint. Email is a convenient way to find it, but it depends on identity disclosure rules. Neither a name nor a short section of a fingerprint is a suitable substitute for a security decision.

The article uses the CH-J Keys2 reader interface and the documented VKS model. It does not upload or request a verification message. For testing, use a public synthetic example, not a bulk search for personal addresses. If using another service, check its current API and limits.

VKS query by fingerprint

curl --fail --silent --show-error --max-time 20 \
  --output verejny-klic.asc \
  https://keys2.ch-j.de/vks/v1/by-fingerprint/6D1542425AAE85E73F4E822AB59161D7683F784AA9E6EA0989D4A2F3990784A9

The specified fingerprint belongs to the public test suite, not your identity. The public-key.asc file must be chosen so as not to overwrite important local content. The command expects a successful HTTP status and limits the wait. For a production client, also add a reasonable size limit and proper redirect handling.

When responding, verify the content type and actual structure. The body should not be an HTML proxy error page. For V6 or post-quantum certificates, you need a corresponding local implementation; an older tool may reject the downloaded content even if the server performed the transfer correctly. Transport and cryptographic compatibility are separate checks.

Long Key ID and email have their own paths

VKS also provides /vks/v1/by-keyid/KEYID and /vks/v1/by-email/EMAIL. The documentation requires uppercase hexadecimal letters without 0x for identifiers. The long Key ID is shorter than the fingerprint and is not as strong an identification for decisive comparison. In addition, its relationship to the entire fingerprint differs in V4 and V6.

Encode the email properly as part of a URL. Plus signs, slashes, or other special characters must not accidentally change the meaning of the path. Do not manually replace just one space. Use a standard URL encoder and be aware that the server may require the exact verified address. Not finding it does not necessarily mean that the owner does not have the key at all.

HKP alternative for established clients

gpg --keyserver hkps://keys2.ch-j.de --recv-keys CELÝ_OTISK

This command actually changes the local keyring by importing the public material found. If you just want to test, use a separate test environment. GnuPG must support the given profile. Don't replace a correct import with the invalid claim that every version of gpg will accept every modern key that Keys2 can issue.

Custom HTTP integration can use /pks/lookup?op=get&search=0xFINGERPRINT. For overview, there is an index operation, depending on the implementation. Do not confuse the metadata overview with the downloaded certificate and do not rely on the search result as proof of personal identity. Fingerprint verification is part of the downstream workflow.

Extended information Keys2

Keys2 documents the /api/v1/keys/FINGERPRINT/info and /history read paths. They can help display algorithms, subkeys, status, and technical history. /api/v1/capabilities describes declared profiles and experimental support. These custom endpoints are not automatically part of every VKS or HKP server.

Public metadata is helpful. Always check the actual downloaded certificate with a compatible tool when importing. The cryptographically_valid value from a specific service's response is its assertion of validation, not an independent local client check. Distinguish this source of trust in your integration documentation.

Bugs, cache and privacy

HTTP 404, 400, 429, and 503 have different meanings. For 404, display not found, for 400, check the query format, for 429, respect constraints, and use limited retry for temporary outages. Don't create an infinite loop that burdens the service and obscures the real state. Bind a successful cache to an accurate query and a valid interpretation of the content.

External federated search is a different operation than local fingerprint retrieval. For email, it may pass personal information to other services and requires appropriate intent and consent. Don't do it covertly as an automatic replacement for every 404. Client logs should also not unnecessarily store full addresses and non-public tokens.

Completing the query

  • The correct server and identifier type was used.
  • The HTTP response contains the expected public certificate.
  • The entire fingerprint matches the trusted reference.
  • The subkeys and necessary relationships are available and valid.
  • Any import and further use correspond to the user's intention.

Good API integration doesn't just look like a successful curl. It can explain non-find, error, and actually verified result. This allows for safe connection by importing into CH-J Tools or another client, without confusing availability on the server with automatic trust in the found owner.

Frequently asked questions

Does recv-keys change the local keyring?

Yes. For a purely isolated test, use a separate environment.

Is external search the same as local VKS GET?

No. It may contact other services and addresses require appropriate consent.

Is JSON info enough as local cryptographic proof?

It is a service claim. Independent verification requires appropriate local certificate review.

Detailed documentation

CH-J Keys2: API →

Hagrid: VKS and HKP documentation →

Keys2: capabilities →

CH-J Public Test Kit →

Biometric unlock and security →

All tutorials by category →