Retrieving a key from a keyserver with gpgme

Leo Gaspard leo at
Thu Sep 10 01:42:46 CEST 2015

On 09/10/2015 12:48 AM, Jeroen Ooms wrote:
> Here is a simplified version of my binding to retrieve some public
> keys from a keyserver:
> Not sure if
> this is the best way of doing this. A few questions:
> 1) Is there any way I can check if gpg.conf has a keyserver
> configured? Or better: can I set a keyserver in gpgme, rather than use
> the one from gpg.conf (i.e. the --keyserver param in gpg)

As far as I can tell, there is no option for setting a keyserver in gpgme.

I once sent a patch [1] to this mailing list, which has been refused for 
not being useful -- maybe it would still work for you, if you can afford 
redistributing a patched gpgme, and it being written by an untrusted 
used doesn't bother you.

Unfortunately, I was not good at mailing lists at that time, so the 
discussion is spread throughout 2012-July to 2012-August... Basically, 
you are supposed to use gpgconf to set this.

Searching again in the manuals today, it seems there is still no ideal 
way of doing this: you should most likely change the configuration file 
before using gpgme -- use [2] on a copied home directory if you do not 
feel like modifying the main gnupg configuration file.

Cheers & HTH,



> 2) Currently the export step fails for some keys. For example: the
> first one succeeds, but the second one does not. Why is this?
> ./lookup 0x7638D0442B90D010e
> ./lookup 0x924FC6ADC80B5E36
> 3) After calling gpgme_op_export_keys for the first time, the all
> subsequent calls to gpgme_op_keylist_next return GPG_ERR_INV_VALUE.
> _______________________________________________
> Gnupg-devel mailing list
> Gnupg-devel at

More information about the Gnupg-devel mailing list