diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gpg-wks-client.c | 19 | ||||
-rw-r--r-- | tools/gpg-wks.h | 1 | ||||
-rw-r--r-- | tools/wks-util.c | 27 |
3 files changed, 44 insertions, 3 deletions
diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c index 2c40d7e17..861a1fc61 100644 --- a/tools/gpg-wks-client.c +++ b/tools/gpg-wks-client.c @@ -62,6 +62,7 @@ enum cmd_and_opt_values aInstallKey, aRemoveKey, aPrintWKDHash, + aPrintWKDURL, oGpgProgram, oSend, @@ -93,6 +94,8 @@ static ARGPARSE_OPTS opts[] = { "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 ")), @@ -236,6 +239,7 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts) case aInstallKey: case aRemoveKey: case aPrintWKDHash: + case aPrintWKDURL: cmd = pargs->r_opt; break; @@ -384,13 +388,24 @@ main (int argc, char **argv) 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. */ diff --git a/tools/gpg-wks.h b/tools/gpg-wks.h index 99969c1ef..9acd7c37f 100644 --- a/tools/gpg-wks.h +++ b/tools/gpg-wks.h @@ -104,6 +104,7 @@ gpg_error_t wks_compute_hu_fname (char **r_fname, const char *addrspec); 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 --*/ diff --git a/tools/wks-util.c b/tools/wks-util.c index d5cfcd874..1c1ac8c0b 100644 --- a/tools/wks-util.c +++ b/tools/wks-util.c @@ -1103,7 +1103,7 @@ wks_cmd_remove_key (const char *userid) } -/* 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) { @@ -1120,3 +1120,28 @@ 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; +} |