Query regarding GPGME python Bindings

Divesh Uttamchandani diveshuttamchandani at gmail.com
Fri Jun 8 11:35:23 CEST 2018


Hi,

I am developing an application using gpgme python bindings.
I want to achieve the following gpg command functionality using gpgme.

gpg --auto-key-locate=local,cert,keyserver,pka \
--keyserver "$KEYSERVER" $recipients \
--sign --encrypt --armor \
--output "$file.sealed" "$file

For achieving this i have broken it down to two parts
1. getting the recipients' key locally/keyserver
2. using these keys to encrypt (and sign the data)

I have idea to achieve the functionality of the second part.
I am doubtful about the first, Though I have tried it in following way, I
want to know if I am correct and if there is a better way?

Way used:
1) Set the keyserver in gpg.conf (in my case gpg.conf resides in ~/.gnupg
say)

2) Set up the context with correct homedir
gpg.Context(home_dir="~/.gnupg")

3) For each recipient use LOCATE mode to get keylist
gpg.Context().keylist(recipient, mode=gpg.constants.keylist.mode.LOCATE)

4) from the list return by #3, confirm the contact from the user and add it
to a list of recipient keys I am maintaining.

5) Finally I can use these keys for encrypting as mentioned in the example
provided in part 2.

Particularly I would like to know is there a way to provide keyserver from
gpgme itself and not in gpg.conf.

I couldn't find details about these variables in the examples provided,
found this mostly using dir() and help() functions in python. Though I also
read the c documentation but I am not sure if it the right way.

Regards,
Divesh Uttamchandani
GitHub <https://github.com/diveshuttam> | Linkedin
<https://www.linkedin.com/in/diveshuttam/> | University Profile
<http://www.bits-pilani.ac.in/spp/f2016045>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20180608/28bf80a6/attachment.html>


More information about the Gnupg-devel mailing list