Search keys on a keyserver with GPGME

José Carlos de Campos zecapistolas at
Thu Dec 13 17:03:38 CET 2012

Hello everyone,

I am developing a app that needs a interface to access to GnuPG, so I
find the GPGME, and I am really happy with this choice. GPGME is
really fantastic and very easy to use.

But I have a problem which I cannot find the right solution.
My app needs to search on a keyserver (anyone) for any public keys
necessary. For example: "To send an encrypted file to someone, first
myApp search on a keyserver for the keys that aren't in the keyring,
import those keys and after that make the encryption."

I have already this piece of code:

// set protocol
err = gpgme_set_protocol(ctx, GPGME_PROTOCOL_OpenPGP);

err = gpgme_set_keylist_mode (ctx, GPGME_KEYLIST_MODE_EXTERN);

// start keylist
err = gpgme_op_keylist_start (ctx, ID.c_str(), 0);

while (!(err = gpgme_op_keylist_next (ctx, &key))) {
        printf ("keyid   : %s\n", key->subkeys?nonnull

// stop keylist
err = gpgme_op_keylist_end (ctx);

but this doesn't return anything...

How can I do this, how can I make a search on a keyserver using GPGME?


More information about the Gnupg-devel mailing list