<div dir="ltr">Hi,<div><br></div><div>I am developing an application using gpgme python bindings.</div><div>I want to achieve the following gpg command functionality using gpgme.</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><div><span style="color:rgb(212,212,212)">gpg --auto-key-locate=local,cert,keyserver,pka \</span></div><div><span style="color:rgb(212,212,212)">        --keyserver </span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(156,220,254)">$KEYSERVER</span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(156,220,254)">$recipients</span><span style="color:rgb(212,212,212)"> \</span></div><div><span style="color:rgb(212,212,212)">        --sign --encrypt --armor \</span></div><div><span style="color:rgb(212,212,212)">        --output </span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(156,220,254)">$file</span><span style="color:rgb(206,145,120)">.sealed"</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(156,220,254)">$file</span></div></div></div><div><br></div><div>For achieving this i have broken it down to two parts</div><div>1. getting the recipients' key locally/keyserver</div><div>2. using these keys to encrypt (and sign the data)</div><div><br></div><div>I have idea to achieve the functionality of the second part.</div><div>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?</div><div><br></div><div>Way used:</div><div>1) Set the keyserver in gpg.conf <span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">(in my case gpg.conf resides in ~/.gnupg say)</span></div><div><br></div><div>2) Set up the context with correct homedir </div><div><div style="text-decoration-style:initial;text-decoration-color:initial"><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">gpg.Context(</span><span style="background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre;color:rgb(156,220,254)">home_dir</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">=</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre"><span style="color:rgb(206,145,120);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">"~/.gnupg"</span>)</span></div><br class="gmail-Apple-interchange-newline">3) For each recipient use LOCATE mode to get keylist<br></div><div><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">gpg.Context().keylist(</span><span style="background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre"><font color="#ce9178">recipient</font></span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">, </span><span style="background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre;color:rgb(156,220,254)">mode</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">=</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;white-space:pre">gpg.constants.keylist.mode.LOCATE)</span></div><div><br></div><div>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.</div><div><br></div><div>5) Finally I can use these keys for encrypting as mentioned in the example provided in part 2.</div><div><br></div><div>Particularly I would like to know is there a way to provide keyserver from gpgme itself and not in gpg.conf. <br></div><div><br></div><div>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. </div><div><br></div><div>Regards,</div><div><div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Divesh Uttamchandani<div><a href="https://github.com/diveshuttam" target="_blank">GitHub</a> | <a href="https://www.linkedin.com/in/diveshuttam/" target="_blank">Linkedin</a> | <a href="http://www.bits-pilani.ac.in/spp/f2016045" target="_blank">University Profile</a></div></div></div></div></div></div></div></div>