jkraemer/mail-gpg — pull request #5 by FewKinG (2013-10-19 13:46:03+00:00)
Title: On the fly keyserver import

I looked into the automatic public key lookup feature. Turns out, this is only poorly supported by the gpgme library and gem. While you can set the keylist mode to `KEYLIST_MODE_EXTERN` this will result in the lookup requests to always use `op=index` as URL query parameter. Following the HKP specs, this kind of request won't return and detailed key information such as the fingerprint or complete public key, which renders this option useless for key lookups.

Given this I implemented the lookup query myself, which wasn't too hard. The HKP specs are pretty simple, you can just pass `op=get&options=mr` to get a machine readable result for your search query, which is just the usual base64 encoded public key(s) with fingerprint(s) and all.

It was more of a challenge to find out the correct public key server URL to use. I wanted this feature to automatically use the URL specified by the GnuPG system settings. Reading these settings isn't supported by the default `gpg`-commandline-tool, only by the `gpgconf`-tool which for me wasn't installed by default.

I ended up with some kind of fallback chain: First, try to get the URL via the `gpgconf`-tool, if installed. Then try manually parsing the gpg.conf file.

Then I also added possibilities to manually specify the keyserver URL.

Let me know what you think of it and/or if you have ideas for improvements to be made.