* tools/gpg-wks-client.c (aPrintWKDURL): New.
(opts): Add option.
(main): Implement.
* tools/wks-util.c (wks_cmd_print_wkd_url): New.
Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit
2f3eebf1865a85f8c09a1c052513260ed55acec6)
Gbp-Pq: Topic from-2.2.15
Gbp-Pq: Name wkd-New-command-print-wkd-url-for-gpg-wks-client.patch
@option{--remove-key} removes a key from that directory, its only
argument is a user-id.
-The command @option{--print-wkd-hash} prints a WKD user id identifier
-and the corresponding mailbox from the user-ids given on the command
+The command @option{--print-wkd-hash} prints the WKD user-id identifiers
+and the corresponding mailboxes from the user-ids given on the command
line or via stdin (one user-id per line).
+The command @option{--print-wkd-url} prints the URLs used to fetch the
+key for the given user-ids from WKD. The meanwhile preferred format
+with sub-domains is used here.
+
@command{gpg-wks-client} is not commonly invoked directly and thus it
is not installed in the bin directory. Here is an example how it can
be invoked manually to check for a Web Key Directory entry for
aInstallKey,
aRemoveKey,
aPrintWKDHash,
+ aPrintWKDURL,
oGpgProgram,
oSend,
"remove a key from a directory"),
ARGPARSE_c (aPrintWKDHash, "print-wkd-hash",
"Print the WKD identifier for the given user ids"),
+ ARGPARSE_c (aPrintWKDURL, "print-wkd-url",
+ "Print the WKD URL for the given user id"),
ARGPARSE_group (301, ("@\nOptions:\n ")),
case aInstallKey:
case aRemoveKey:
case aPrintWKDHash:
+ case aPrintWKDURL:
cmd = pargs->r_opt;
break;
break;
case aPrintWKDHash:
+ case aPrintWKDURL:
if (!argc)
- err = proc_userid_from_stdin (wks_cmd_print_wkd_hash, "printing hash");
+ {
+ if (cmd == aPrintWKDHash)
+ err = proc_userid_from_stdin (wks_cmd_print_wkd_hash,
+ "printing WKD hash");
+ else
+ err = proc_userid_from_stdin (wks_cmd_print_wkd_url,
+ "printing WKD URL");
+ }
else
{
for (err = delayed_err = 0; !err && argc; argc--, argv++)
{
- err = wks_cmd_print_wkd_hash (*argv);
+ if (cmd == aPrintWKDHash)
+ err = wks_cmd_print_wkd_hash (*argv);
+ else
+ err = wks_cmd_print_wkd_url (*argv);
if (gpg_err_code (err) == GPG_ERR_INV_USER_ID)
{
/* Diagnostic already printed. */
gpg_error_t wks_cmd_install_key (const char *fname, const char *userid);
gpg_error_t wks_cmd_remove_key (const char *userid);
gpg_error_t wks_cmd_print_wkd_hash (const char *userid);
+gpg_error_t wks_cmd_print_wkd_url (const char *userid);
/*-- wks-receive.c --*/
}
-/* Print the WKD hash for the user ids to stdout. */
+/* Print the WKD hash for the user id to stdout. */
gpg_error_t
wks_cmd_print_wkd_hash (const char *userid)
{
xfree (addrspec);
return err;
}
+
+
+/* Print the WKD URL for the user id to stdout. */
+gpg_error_t
+wks_cmd_print_wkd_url (const char *userid)
+{
+ gpg_error_t err;
+ char *addrspec, *fname;
+ char *domain;
+
+ err = wks_fname_from_userid (userid, 1, &fname, &addrspec);
+ if (err)
+ return err;
+
+ domain = strchr (addrspec, '@');
+ if (domain)
+ *domain++ = 0;
+
+ es_printf ("https://openpgpkey.%s/.well-known/openpgpkey/%s/hu/%s?l=%s\n",
+ domain, domain, fname, addrspec);
+
+ xfree (fname);
+ xfree (addrspec);
+ return err;
+}