python GPGME bindings and key signatures
Tobias Mueller
muelli at cryptobitch.de
Mon Nov 5 12:14:45 CET 2018
Hi,
On Mon, 2018-11-05 at 00:20 -0500, brent s. wrote:
>
> however, this is empty in python's bindings:
>
> _________________________________________________________________
> > > > import os
> > > > os.environ['GNUPGHOME']
>
> '/var/tmp/python_testing/gpg/homedir'
> > > > import gpg
> > > > ctx = gpg.Context()
> > > > k = ctx.get_key('C548200C7F6AA9541F6EDFF65A6D013706B6BE26')
> > > > k.uids[0].signatures
>
> []
> > > >
>
> _________________________________________________________________
>
>
yeah, this is one of the peculiarities of the gpgme interface.
You have to request the key list with signatures.
I'd link to the documentation, but as there is still no full HTML
version I cannot easily press Ctrl+F and search.
I have the following in my code:
# *sigh* gpgme is killing me. With gpgme 1.8 we have to
# set_keylist_mode before we can call keylist. With gpgme 1.9
# keylist takes a mode argument and overrides whatever has been
# set before. In order to come with something compatible with both
# 1.8 and 1.9 we have to set_keylist_mode and NOT call ctx.keylist
# but rather the bare op_keylist_all. In 1.8 that requires two
# arguments.
mode = gpg.constants.keylist.mode.LOCAL | gpg.constants.keylist.mode.SIGS
secret = False
ctx.set_keylist_mode(mode)
keys = list(ctx.op_keylist_all(key.fpr, secret))
# With gpgme 1.9 we can simply do:
# keys = list(ctx.keylist(key.fpr), mode=mode)
HTH,
Tobi
More information about the Gnupg-devel
mailing list