gpgme doesn't seem to return the signatures

Marcus Brinkmann marcus.brinkmann at ruhr-uni-bochum.de
Fri Jun 3 00:10:38 CEST 2005


Hi,

At Wed, 18 May 2005 11:58:26 +0200,
Folkert van Heusden <folkert at vanheusden.com> wrote:
>         (void)gpgme_check_version(NULL);
>         err = gpgme_new(&ctx);
>         err = gpgme_op_keylist_start (ctx, NULL, 0);
> 	err = gpgme_op_keylist_next(ctx, &r_key);
> 	gpgme_user_id_t uids = r_key -> uids;
> 	...for each uid...
> 		gpgme_key_sig_t sigs = uids -> signatures;
> 
> Now sigs in this case is *always* NULL!
> And I've verified (with gpg --list-sigs) that *all* keys have one or more signature.

You need to set the keylist mode.  By default, signatures are not
included to speed things up a bit.  If you need them, you need to use
the keylist mode GPGME_KEYLIST_MODE_SIGS.  From the manual (*Key
Listing Mode*):

@item GPGME_KEYLIST_MODE_SIGS
The @code{GPGME_KEYLIST_MODE_SIGS} symbol specifies that the key
signatures should be included in the listed keys.

From tests/gpg/t-keylist-sig.c:

  int mode;
  mode = gpgme_get_keylist_mode (ctx);
  mode |= GPGME_KEYLIST_MODE_SIGS;
  err = gpgme_set_keylist_mode (ctx, mode);
  fail_if_err (err);

> Oh, and do I need to free-up something after I do gpgme_op_keylist_next?

You need to eventually dereference the key to release its storage.
This is done with gpgme_key_unref ().  From the manual, (*Manipulating
Keys*):

@deftypefun void gpgme_key_unref (@w{gpgme_key_t @var{key}})
The function @code{gpgme_key_unref} releases a reference for the key
@var{key}.  If this was the last reference, the key will be destroyed
and all resources associated to it will be released.
@end deftypefun

Thanks,
Marcus




More information about the Gnupg-devel mailing list