1 /* gpg-wks-client.c - A client for the Web Key Service protocols.
2 * Copyright (C) 2016, 2022 g10 Code GmbH
3 * Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik
5 * This file is part of GnuPG.
7 * This file is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, see <https://www.gnu.org/licenses/>.
19 * SPDX-License-Identifier: LGPL-2.1-or-later
27 #include <sys/types.h>
30 #define INCLUDED_BY_MAIN_MODULE 1
31 #include "../common/util.h"
32 #include "../common/status.h"
33 #include "../common/i18n.h"
34 #include "../common/sysutils.h"
35 #include "../common/init.h"
36 #include "../common/asshelp.h"
37 #include "../common/userids.h"
38 #include "../common/ccparray.h"
39 #include "../common/exectool.h"
40 #include "../common/mbox-util.h"
41 #include "../common/name-value.h"
42 #include "../common/comopt.h"
43 #include "call-dirmngr.h"
44 #include "mime-maker.h"
45 #include "send-mail.h"
49 /* Constants to identify the commands and options. */
50 enum cmd_and_opt_values
85 /* The list of commands and options. */
86 static gpgrt_opt_t opts[] = {
87 ARGPARSE_group (300, ("@Commands:\n ")),
89 ARGPARSE_c (aSupported, "supported",
90 ("check whether provider supports WKS")),
91 ARGPARSE_c (aCheck, "check",
92 ("check whether a key is available")),
93 ARGPARSE_c (aCreate, "create",
94 ("create a publication request")),
95 ARGPARSE_c (aReceive, "receive",
96 ("receive a MIME confirmation request")),
97 ARGPARSE_c (aRead, "read",
98 ("receive a plain text confirmation request")),
99 ARGPARSE_c (aMirror, "mirror",
100 "mirror an LDAP directory"),
101 ARGPARSE_c (aInstallKey, "install-key",
102 "install a key into a directory"),
103 ARGPARSE_c (aRemoveKey, "remove-key",
104 "remove a key from a directory"),
105 ARGPARSE_c (aPrintWKDHash, "print-wkd-hash",
106 "print the WKD identifier for the given user ids"),
107 ARGPARSE_c (aPrintWKDURL, "print-wkd-url",
108 "print the WKD URL for the given user id"),
110 ARGPARSE_group (301, ("@\nOptions:\n ")),
112 ARGPARSE_s_n (oVerbose, "verbose", ("verbose")),
113 ARGPARSE_s_n (oQuiet, "quiet", ("be somewhat more quiet")),
114 ARGPARSE_s_s (oDebug, "debug", "@"),
115 ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
116 ARGPARSE_s_n (oSend, "send", "send the mail using sendmail"),
117 ARGPARSE_s_s (oOutput, "output", "|FILE|write the mail to FILE"),
118 ARGPARSE_s_i (oStatusFD, "status-fd", N_("|FD|write status info to this FD")),
119 ARGPARSE_s_n (oNoAutostart, "no-autostart", "@"),
120 ARGPARSE_s_n (oWithColons, "with-colons", "@"),
121 ARGPARSE_s_s (oBlacklist, "blacklist", "@"),
122 ARGPARSE_s_s (oDirectory, "directory", "@"),
123 ARGPARSE_s_n (oAddRevocs, "add-revocs", "add revocation certificates"),
125 ARGPARSE_s_s (oFakeSubmissionAddr, "fake-submission-addr", "@"),
131 /* The list of supported debug flags. */
132 static struct debug_flags_s debug_flags [] =
134 { DBG_MIME_VALUE , "mime" },
135 { DBG_PARSER_VALUE , "parser" },
136 { DBG_CRYPTO_VALUE , "crypto" },
137 { DBG_MEMORY_VALUE , "memory" },
138 { DBG_MEMSTAT_VALUE, "memstat" },
139 { DBG_IPC_VALUE , "ipc" },
140 { DBG_EXTPROG_VALUE, "extprog" },
146 /* Value of the option --fake-submission-addr. */
147 const char *fake_submission_addr;
149 /* An array with blacklisted addresses and its length. Use
150 * is_in_blacklist to check. */
151 static char **blacklist_array;
152 static size_t blacklist_array_len;
155 static void wrong_args (const char *text) GPGRT_ATTR_NORETURN;
156 static void add_blacklist (const char *fname);
157 static gpg_error_t proc_userid_from_stdin (gpg_error_t (*func)(const char *),
159 static gpg_error_t command_supported (char *userid);
160 static gpg_error_t command_check (char *userid);
161 static gpg_error_t command_send (const char *fingerprint, const char *userid);
162 static gpg_error_t encrypt_response (estream_t *r_output, estream_t input,
163 const char *addrspec,
164 const char *fingerprint);
165 static gpg_error_t read_confirmation_request (estream_t msg);
166 static gpg_error_t command_receive_cb (void *opaque,
167 const char *mediatype, estream_t fp,
169 static gpg_error_t command_mirror (char *domain[]);
173 /* Print usage information and provide strings for help. */
175 my_strusage( int level )
181 case 9: p = "LGPL-2.1-or-later"; break;
182 case 11: p = "gpg-wks-client"; break;
183 case 12: p = "@GNUPG@"; break;
184 case 13: p = VERSION; break;
185 case 14: p = GNUPG_DEF_COPYRIGHT_LINE; break;
186 case 17: p = PRINTABLE_OS_NAME; break;
187 case 19: p = ("Please report bugs to <@EMAIL@>.\n"); break;
191 p = ("Usage: gpg-wks-client [command] [options] [args] (-h for help)");
194 p = ("Syntax: gpg-wks-client [command] [options] [args]\n"
195 "Client for the Web Key Service\n");
198 default: p = NULL; break;
205 wrong_args (const char *text)
207 es_fprintf (es_stderr, _("usage: %s [options] %s\n"),
208 gpgrt_strusage (11), text);
214 /* Command line parsing. */
215 static enum cmd_and_opt_values
216 parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
218 enum cmd_and_opt_values cmd = 0;
219 int no_more_options = 0;
221 while (!no_more_options && gpgrt_argparse (NULL, pargs, popts))
223 switch (pargs->r_opt)
225 case oQuiet: opt.quiet = 1; break;
226 case oVerbose: opt.verbose++; break;
228 if (parse_debug_flag (pargs->r.ret_str, &opt.debug, debug_flags))
230 pargs->r_opt = ARGPARSE_INVALID_ARG;
231 pargs->err = ARGPARSE_PRINT_ERROR;
236 opt.gpg_program = pargs->r.ret_str;
239 opt.directory = pargs->r.ret_str;
242 opt.use_sendmail = 1;
245 opt.output = pargs->r.ret_str;
247 case oFakeSubmissionAddr:
248 fake_submission_addr = pargs->r.ret_str;
251 wks_set_status_fd (translate_sys2libc_fd_int (pargs->r.ret_int, 1));
257 opt.no_autostart = 1;
260 add_blacklist (pargs->r.ret_str);
279 default: pargs->err = ARGPARSE_PRINT_ERROR; break;
288 /* gpg-wks-client main. */
290 main (int argc, char **argv)
292 gpg_error_t err, delayed_err;
293 gpgrt_argparse_t pargs;
294 enum cmd_and_opt_values cmd;
296 gnupg_reopen_std ("gpg-wks-client");
297 gpgrt_set_strusage (my_strusage);
298 log_set_prefix ("gpg-wks-client", GPGRT_LOG_WITH_PREFIX);
300 /* Make sure that our subsystems are ready. */
302 init_common_subsystems (&argc, &argv);
304 assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
305 setup_libassuan_logging (&opt.debug, NULL);
307 /* Parse the command line. */
310 pargs.flags = ARGPARSE_FLAG_KEEP;
311 cmd = parse_arguments (&pargs, opts);
312 gpgrt_argparse (NULL, &pargs, NULL);
314 /* Check if gpg is build with sendmail support */
315 if (opt.use_sendmail && !NAME_OF_SENDMAIL[0])
317 err = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
318 log_error ("sending mail is not supported in this build: %s\n",
322 if (log_get_errorcount (0))
325 /* Process common component options. Note that we set the config
326 * dir only here so that --homedir will have an effect. */
327 gpgrt_set_confdir (GPGRT_CONFDIR_SYS, gnupg_sysconfdir ());
328 gpgrt_set_confdir (GPGRT_CONFDIR_USER, gnupg_homedir ());
329 if (parse_comopt (GNUPG_MODULE_NAME_CONNECT_AGENT, opt.verbose > 1))
331 if (comopt.no_autostart)
332 opt.no_autostart = 1;
334 /* Print a warning if an argument looks like an option. */
335 if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
339 for (i=0; i < argc; i++)
340 if (argv[i][0] == '-' && argv[i][1] == '-')
341 log_info (("NOTE: '%s' is not considered an option\n"), argv[i]);
344 /* Set defaults for non given options. */
345 if (!opt.gpg_program)
346 opt.gpg_program = gnupg_module_name (GNUPG_MODULE_NAME_GPG);
349 opt.directory = "openpgpkey";
351 /* Tell call-dirmngr what options we want. */
352 set_dirmngr_options (opt.verbose, (opt.debug & DBG_IPC_VALUE),
356 /* Check that the top directory exists. */
357 if (cmd == aInstallKey || cmd == aRemoveKey || cmd == aMirror)
361 if (gnupg_stat (opt.directory, &sb))
363 err = gpg_error_from_syserror ();
364 log_error ("error accessing directory '%s': %s\n",
365 opt.directory, gpg_strerror (err));
368 if (!S_ISDIR(sb.st_mode))
370 log_error ("error accessing directory '%s': %s\n",
371 opt.directory, "not a directory");
372 err = gpg_error (GPG_ERR_ENOENT);
377 /* Run the selected command. */
383 for (; argc; argc--, argv++)
384 command_supported (*argv);
390 wrong_args ("--supported DOMAIN");
391 err = command_supported (argv[0]);
392 if (err && gpg_err_code (err) != GPG_ERR_FALSE)
393 log_error ("checking support failed: %s\n", gpg_strerror (err));
399 wrong_args ("--create FINGERPRINT USER-ID");
400 err = command_send (argv[0], argv[1]);
402 log_error ("creating request failed: %s\n", gpg_strerror (err));
407 wrong_args ("--receive < MIME-DATA");
408 err = wks_receive (es_stdin, command_receive_cb, NULL);
410 log_error ("processing mail failed: %s\n", gpg_strerror (err));
415 wrong_args ("--read < WKS-DATA");
416 err = read_confirmation_request (es_stdin);
418 log_error ("processing mail failed: %s\n", gpg_strerror (err));
423 wrong_args ("--check USER-ID");
424 err = command_check (argv[0]);
429 err = command_mirror (NULL);
431 err = command_mirror (argv);
436 err = wks_cmd_install_key (NULL, NULL);
438 err = wks_cmd_install_key (*argv, argv[1]);
440 wrong_args ("--install-key [FILE|FINGERPRINT USER-ID]");
445 wrong_args ("--remove-key USER-ID");
446 err = wks_cmd_remove_key (*argv);
453 if (cmd == aPrintWKDHash)
454 err = proc_userid_from_stdin (wks_cmd_print_wkd_hash,
455 "printing WKD hash");
457 err = proc_userid_from_stdin (wks_cmd_print_wkd_url,
462 for (err = delayed_err = 0; !err && argc; argc--, argv++)
464 if (cmd == aPrintWKDHash)
465 err = wks_cmd_print_wkd_hash (*argv);
467 err = wks_cmd_print_wkd_url (*argv);
468 if (gpg_err_code (err) == GPG_ERR_INV_USER_ID)
470 /* Diagnostic already printed. */
475 log_error ("printing hash failed: %s\n", gpg_strerror (err));
490 wks_write_status (STATUS_FAILURE, "- %u", err);
491 else if (log_get_errorcount (0))
492 wks_write_status (STATUS_FAILURE, "- %u", GPG_ERR_GENERAL);
494 wks_write_status (STATUS_SUCCESS, NULL);
495 return (err || log_get_errorcount (0))? 1:0;
500 /* Read a file FNAME into a buffer and return that malloced buffer.
501 * Caller must free the buffer. On error NULL is returned, on success
502 * the valid length of the buffer is stored at R_LENGTH. The returned
503 * buffer is guaranteed to be Nul terminated. */
505 read_file (const char *fname, size_t *r_length)
511 if (!strcmp (fname, "-"))
513 size_t nread, bufsize = 0;
524 buf = xmalloc (bufsize+1);
526 buf = xrealloc (buf, bufsize+1);
528 nread = es_fread (buf+buflen, 1, NCHUNK, fp);
529 if (nread < NCHUNK && es_ferror (fp))
531 log_error ("error reading '[stdin]': %s\n", strerror (errno));
537 while (nread == NCHUNK);
544 fp = es_fopen (fname, "rb");
547 log_error ("can't open '%s': %s\n", fname, strerror (errno));
551 if (fstat (es_fileno (fp), &st))
553 log_error ("can't stat '%s': %s\n", fname, strerror (errno));
559 buf = xmalloc (buflen+1);
560 if (es_fread (buf, buflen, 1, fp) != 1)
562 log_error ("error reading '%s': %s\n", fname, strerror (errno));
577 cmp_blacklist (const void *arg_a, const void *arg_b)
579 const char *a = *(const char **)arg_a;
580 const char *b = *(const char **)arg_b;
581 return strcmp (a, b);
585 /* Add a blacklist to our global table. This is called during option
586 * parsing and thus any use of log_error will eventually stop further
589 add_blacklist (const char *fname)
594 size_t arraysize, arrayidx;
596 buffer = read_file (fname, NULL);
600 /* Estimate the number of entries by counting the non-comment lines. */
601 arraysize = 2; /* For the first and an extra NULL item. */
602 for (p=buffer; *p; p++)
603 if (*p == '\n' && p[1] && p[1] != '#')
606 array = xcalloc (arraysize, sizeof *array);
609 /* Loop over all lines. */
610 for (p = buffer; p && *p; p = pend)
612 pend = strchr (p, '\n');
616 if (!*p || *p == '#' )
619 log_assert (arrayidx < arraysize);
623 log_assert (arrayidx < arraysize);
625 qsort (array, arrayidx, sizeof *array, cmp_blacklist);
627 blacklist_array = array;
628 blacklist_array_len = arrayidx;
629 gpgrt_annotate_leaked_object (buffer);
630 gpgrt_annotate_leaked_object (blacklist_array);
634 /* Return true if NAME is in a blacklist. */
636 is_in_blacklist (const char *name)
638 if (!name || !blacklist_array)
640 return !!bsearch (&name, blacklist_array, blacklist_array_len,
641 sizeof *blacklist_array, cmp_blacklist);
646 /* Read user ids from stdin and call FUNC for each user id. TEXT is
647 * used for error messages. */
649 proc_userid_from_stdin (gpg_error_t (*func)(const char *), const char *text)
652 gpg_error_t delayed_err = 0;
656 /* If we are on a terminal disable buffering to get direct response. */
657 if (gnupg_isatty (es_fileno (es_stdin))
658 && gnupg_isatty (es_fileno (es_stdout)))
660 es_setvbuf (es_stdin, NULL, _IONBF, 0);
661 es_setvbuf (es_stdout, NULL, _IOLBF, 0);
664 while (es_fgets (line, sizeof line - 1, es_stdin))
667 if (!n || line[n-1] != '\n')
669 err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG
670 : GPG_ERR_INCOMPLETE_LINE);
671 log_error ("error reading stdin: %s\n", gpg_strerror (err));
676 if (gpg_err_code (err) == GPG_ERR_INV_USER_ID)
682 log_error ("%s failed: %s\n", text, gpg_strerror (err));
684 if (es_ferror (es_stdin))
686 err = gpg_error_from_syserror ();
687 log_error ("error reading stdin: %s\n", gpg_strerror (err));
700 /* Add the user id UID to the key identified by FINGERPRINT. */
702 add_user_id (const char *fingerprint, const char *uid)
706 const char **argv = NULL;
708 ccparray_init (&ccp, 0);
710 ccparray_put (&ccp, "--no-options");
712 ccparray_put (&ccp, "--quiet");
714 ccparray_put (&ccp, "--verbose");
715 ccparray_put (&ccp, "--batch");
716 ccparray_put (&ccp, "--always-trust");
717 ccparray_put (&ccp, "--quick-add-uid");
718 ccparray_put (&ccp, fingerprint);
719 ccparray_put (&ccp, uid);
721 ccparray_put (&ccp, NULL);
722 argv = ccparray_get (&ccp, NULL);
725 err = gpg_error_from_syserror ();
728 err = gnupg_exec_tool_stream (opt.gpg_program, argv, NULL,
733 log_error ("adding user id failed: %s\n", gpg_strerror (err));
744 struct decrypt_stream_parm_s
752 decrypt_stream_status_cb (void *opaque, const char *keyword, char *args)
754 struct decrypt_stream_parm_s *decinfo = opaque;
757 log_debug ("gpg status: %s %s\n", keyword, args);
758 if (!strcmp (keyword, "DECRYPTION_KEY") && !decinfo->fpr)
760 const char *fields[3];
762 if (split_fields (args, fields, DIM (fields)) >= 3)
764 decinfo->fpr = xstrdup (fields[0]);
765 decinfo->mainfpr = xstrdup (fields[1]);
766 decinfo->otrust = *fields[2];
771 /* Decrypt the INPUT stream to a new stream which is stored at success
774 decrypt_stream (estream_t *r_output, struct decrypt_stream_parm_s *decinfo,
783 memset (decinfo, 0, sizeof *decinfo);
785 output = es_fopenmem (0, "w+b");
788 err = gpg_error_from_syserror ();
789 log_error ("error allocating memory buffer: %s\n", gpg_strerror (err));
793 ccparray_init (&ccp, 0);
795 ccparray_put (&ccp, "--no-options");
796 /* We limit the output to 64 KiB to avoid DoS using compression
797 * tricks. A regular client will anyway only send a minimal key;
798 * that is one w/o key signatures and attribute packets. */
799 ccparray_put (&ccp, "--max-output=0x10000");
801 ccparray_put (&ccp, "--quiet");
803 ccparray_put (&ccp, "--verbose");
804 ccparray_put (&ccp, "--batch");
805 ccparray_put (&ccp, "--status-fd=2");
806 ccparray_put (&ccp, "--decrypt");
807 ccparray_put (&ccp, "--");
809 ccparray_put (&ccp, NULL);
810 argv = ccparray_get (&ccp, NULL);
813 err = gpg_error_from_syserror ();
816 err = gnupg_exec_tool_stream (opt.gpg_program, argv, input,
818 decrypt_stream_status_cb, decinfo);
819 if (!err && (!decinfo->fpr || !decinfo->mainfpr || !decinfo->otrust))
820 err = gpg_error (GPG_ERR_INV_ENGINE);
823 log_error ("decryption failed: %s\n", gpg_strerror (err));
826 else if (opt.verbose)
827 log_info ("decryption succeeded\n");
836 xfree (decinfo->fpr);
837 xfree (decinfo->mainfpr);
838 memset (decinfo, 0, sizeof *decinfo);
846 /* Return the submission address for the address or just the domain in
847 * ADDRSPEC. The submission address is stored as a malloced string at
848 * R_SUBMISSION_ADDRESS. At R_POLICY the policy flags of the domain
849 * are stored. The caller needs to free them with wks_free_policy.
850 * The function returns an error code on failure to find a submission
851 * address or policy file. Note: The function may store NULL at
852 * R_SUBMISSION_ADDRESS but return success to indicate that the web
853 * key directory is supported but not the web key service. As per WKD
854 * specs a policy file is always required and will thus be return on
857 get_policy_and_sa (const char *addrspec, int silent,
858 policy_flags_t *r_policy, char **r_submission_address)
861 estream_t mbuf = NULL;
864 policy_flags_t policy = NULL;
865 char *submission_to = NULL;
867 *r_submission_address = NULL;
870 domain = strchr (addrspec, '@');
876 s = domain? domain : addrspec;
877 es_write_sanitized (es_stdout, s, strlen (s), ":", NULL);
878 es_putc (':', es_stdout);
881 /* We first try to get the submission address from the policy file
882 * (this is the new method). If both are available we check that
883 * they match and print a warning if not. In the latter case we
884 * keep on using the one from the submission-address file. */
885 err = wkd_get_policy_flags (addrspec, &mbuf);
886 if (err && gpg_err_code (err) != GPG_ERR_NO_DATA
887 && gpg_err_code (err) != GPG_ERR_NO_NAME)
889 if (!opt.with_colons)
890 log_error ("error reading policy flags for '%s': %s\n",
891 domain, gpg_strerror (err));
896 if (!opt.with_colons)
897 log_error ("provider for '%s' does NOT support the Web Key Directory\n",
899 err = gpg_error (GPG_ERR_FALSE);
903 policy = xtrycalloc (1, sizeof *policy);
905 err = gpg_error_from_syserror ();
907 err = wks_parse_policy (policy, mbuf, 1);
913 err = wkd_get_submission_address (addrspec, &submission_to);
914 if (err && !policy->submission_address)
916 if (!silent && !opt.with_colons)
917 log_error (_("error looking up submission address for domain '%s'"
918 ": %s\n"), domain, gpg_strerror (err));
919 if (!silent && gpg_err_code (err) == GPG_ERR_NO_DATA && !opt.with_colons)
920 log_error (_("this domain probably doesn't support WKS.\n"));
924 if (submission_to && policy->submission_address
925 && ascii_strcasecmp (submission_to, policy->submission_address))
926 log_info ("Warning: different submission addresses (sa=%s, po=%s)\n",
927 submission_to, policy->submission_address);
929 if (!submission_to && policy->submission_address)
931 submission_to = xtrystrdup (policy->submission_address);
934 err = gpg_error_from_syserror ();
940 *r_submission_address = submission_to;
941 submission_to = NULL;
947 if (*r_policy && !*r_submission_address)
948 es_fprintf (es_stdout, "1:0::");
949 else if (*r_policy && *r_submission_address)
950 es_fprintf (es_stdout, "1:1::");
951 else if (err && !(gpg_err_code (err) == GPG_ERR_FALSE
952 || gpg_err_code (err) == GPG_ERR_NO_DATA
953 || gpg_err_code (err) == GPG_ERR_UNKNOWN_HOST))
954 es_fprintf (es_stdout, "0:0:%d:", err);
956 es_fprintf (es_stdout, "0:0::");
959 es_fprintf (es_stdout, "%u:%u:%u:",
960 (*r_policy)->protocol_version,
961 (*r_policy)->auth_submit,
962 (*r_policy)->mailbox_only);
964 es_putc ('\n', es_stdout);
967 xfree (submission_to);
968 wks_free_policy (policy);
976 /* Check whether the provider supports the WKS protocol. */
978 command_supported (char *userid)
981 char *addrspec = NULL;
982 char *submission_to = NULL;
983 policy_flags_t policy = NULL;
985 if (!strchr (userid, '@'))
987 char *tmp = xstrconcat ("foo@", userid, NULL);
988 addrspec = mailbox_from_userid (tmp, 0);
992 addrspec = mailbox_from_userid (userid, 0);
995 log_error (_("\"%s\" is not a proper mail address\n"), userid);
996 err = gpg_error (GPG_ERR_INV_USER_ID);
1000 /* Get the submission address. */
1001 err = get_policy_and_sa (addrspec, 1, &policy, &submission_to);
1002 if (err || !submission_to)
1005 || gpg_err_code (err) == GPG_ERR_FALSE
1006 || gpg_err_code (err) == GPG_ERR_NO_DATA
1007 || gpg_err_code (err) == GPG_ERR_UNKNOWN_HOST
1010 /* FALSE is returned if we already figured out that even the
1011 * Web Key Directory is not supported and thus printed an
1013 if (opt.verbose && gpg_err_code (err) != GPG_ERR_FALSE
1014 && !opt.with_colons)
1016 if (gpg_err_code (err) == GPG_ERR_NO_DATA)
1017 log_info ("provider for '%s' does NOT support WKS\n",
1020 log_info ("provider for '%s' does NOT support WKS (%s)\n",
1021 addrspec, gpg_strerror (err));
1023 err = gpg_error (GPG_ERR_FALSE);
1024 if (!opt.with_colons)
1025 log_inc_errorcount ();
1030 if (opt.verbose && !opt.with_colons)
1031 log_info ("provider for '%s' supports WKS\n", addrspec);
1034 wks_free_policy (policy);
1036 xfree (submission_to);
1043 /* Check whether the key for USERID is available in the WKD. */
1045 command_check (char *userid)
1048 char *addrspec = NULL;
1049 estream_t key = NULL;
1051 uidinfo_list_t mboxes = NULL;
1055 addrspec = mailbox_from_userid (userid, 0);
1058 log_error (_("\"%s\" is not a proper mail address\n"), userid);
1059 err = gpg_error (GPG_ERR_INV_USER_ID);
1063 /* Get the submission address. */
1064 err = wkd_get_key (addrspec, &key);
1065 switch (gpg_err_code (err))
1069 log_info ("public key for '%s' found via WKD\n", addrspec);
1070 /* Fixme: Check that the key contains the user id. */
1073 case GPG_ERR_NO_DATA: /* No such key. */
1075 log_info ("public key for '%s' NOT found via WKD\n", addrspec);
1076 err = gpg_error (GPG_ERR_NO_PUBKEY);
1077 log_inc_errorcount ();
1080 case GPG_ERR_UNKNOWN_HOST:
1082 log_info ("error looking up '%s' via WKD: %s\n",
1083 addrspec, gpg_strerror (err));
1084 err = gpg_error (GPG_ERR_NOT_SUPPORTED);
1088 log_error ("error looking up '%s' via WKD: %s\n",
1089 addrspec, gpg_strerror (err));
1096 /* Look closer at the key. */
1097 err = wks_list_key (key, &fpr, &mboxes);
1100 log_error ("error parsing key: %s\n", gpg_strerror (err));
1101 err = gpg_error (GPG_ERR_NO_PUBKEY);
1106 log_info ("fingerprint: %s\n", fpr);
1108 for (sl = mboxes; sl; sl = sl->next)
1110 if (sl->mbox && !strcmp (sl->mbox, addrspec))
1114 log_info (" user-id: %s\n", sl->uid);
1115 log_info (" created: %s\n", asctimestamp (sl->created));
1117 log_info (" addr-spec: %s\n", sl->mbox);
1118 if (sl->expired || sl->revoked)
1119 log_info (" flags:%s%s\n",
1120 sl->expired? " expired":"", sl->revoked?" revoked":"");
1125 log_error ("public key for '%s' has no user id with the mail address\n",
1127 err = gpg_error (GPG_ERR_CERT_REVOKED);
1132 free_uidinfo_list (mboxes);
1140 /* Locate the key by fingerprint and userid and send a publication
1143 command_send (const char *fingerprint, const char *userid)
1146 KEYDB_SEARCH_DESC desc;
1147 char *addrspec = NULL;
1148 estream_t key = NULL;
1149 estream_t keyenc = NULL;
1150 char *submission_to = NULL;
1151 mime_maker_t mime = NULL;
1152 policy_flags_t policy = NULL;
1154 int posteo_hack = 0;
1156 uidinfo_list_t uidlist = NULL;
1157 uidinfo_list_t uid, thisuid;
1161 if (classify_user_id (fingerprint, &desc, 1)
1162 || desc.mode != KEYDB_SEARCH_MODE_FPR)
1164 log_error (_("\"%s\" is not a fingerprint\n"), fingerprint);
1165 err = gpg_error (GPG_ERR_INV_NAME);
1169 addrspec = mailbox_from_userid (userid, 0);
1172 log_error (_("\"%s\" is not a proper mail address\n"), userid);
1173 err = gpg_error (GPG_ERR_INV_USER_ID);
1176 err = wks_get_key (&key, fingerprint, addrspec, 0, 1);
1180 domain = strchr (addrspec, '@');
1181 log_assert (domain);
1184 /* Get the submission address. */
1185 if (fake_submission_addr)
1187 policy = xcalloc (1, sizeof *policy);
1188 submission_to = xstrdup (fake_submission_addr);
1193 err = get_policy_and_sa (addrspec, 0, &policy, &submission_to);
1198 log_error (_("this domain probably doesn't support WKS.\n"));
1199 err = gpg_error (GPG_ERR_NO_DATA);
1204 log_info ("submitting request to '%s'\n", submission_to);
1206 if (policy->auth_submit)
1207 log_info ("no confirmation required for '%s'\n", addrspec);
1209 /* In case the key has several uids with the same addr-spec we will
1210 * use the newest one. */
1211 err = wks_list_key (key, NULL, &uidlist);
1214 log_error ("error parsing key: %s\n",gpg_strerror (err));
1215 err = gpg_error (GPG_ERR_NO_PUBKEY);
1221 for (uid = uidlist; uid; uid = uid->next)
1224 continue; /* Should not happen anyway. */
1225 if (policy->mailbox_only && ascii_strcasecmp (uid->uid, uid->mbox))
1226 continue; /* UID has more than just the mailbox. */
1230 log_info ("ignoring expired user id '%s'\n", uid->uid);
1234 if (uid->created > thistime)
1236 thistime = uid->created;
1241 thisuid = uidlist; /* This is the case for a missing timestamp. */
1244 log_error ("public key %s has no mail address '%s'\n",
1245 fingerprint, addrspec);
1246 err = gpg_error (GPG_ERR_INV_USER_ID);
1251 log_info ("submitting key with user id '%s'\n", thisuid->uid);
1253 /* If we have more than one user id we need to filter the key to
1254 * include only THISUID. */
1260 err = wks_filter_uid (&newkey, key, thisuid->uid, 1);
1263 log_error ("error filtering key: %s\n", gpg_strerror (err));
1264 err = gpg_error (GPG_ERR_NO_PUBKEY);
1271 if (policy->mailbox_only
1272 && (!thisuid->mbox || ascii_strcasecmp (thisuid->uid, thisuid->mbox)))
1274 log_info ("Warning: policy requires 'mailbox-only'"
1275 " - adding user id '%s'\n", addrspec);
1276 err = add_user_id (fingerprint, addrspec);
1280 /* Need to get the key again. This time we request filtering
1281 * for the full user id, so that we do not need check and filter
1285 err = wks_get_key (&key, fingerprint, addrspec, 1, 1);
1292 if (es_fseek (key, 0, SEEK_END))
1294 err = gpg_error_from_syserror ();
1295 log_error ("error seeking stream: %s\n", gpg_strerror (err));
1298 err = wks_find_add_revocs (key, addrspec);
1301 log_error ("error finding revocations for '%s': %s\n",
1302 addrspec, gpg_strerror (err));
1308 /* Now put the armor around the key. */
1313 err = wks_armor_key (&newkey, key,
1315 /* */ : ("Content-Type: application/pgp-keys\n"
1319 log_error ("error armoring key: %s\n", gpg_strerror (err));
1326 /* Hack to support posteo but let them disable this by setting the
1327 * new policy-version flag. */
1328 if (policy->protocol_version < 3
1329 && !ascii_strcasecmp (domain, "posteo.de"))
1331 log_info ("Warning: Using draft-1 method for domain '%s'\n", domain);
1336 /* Encrypt the key part. */
1340 err = encrypt_response (&keyenc, key, submission_to, fingerprint);
1348 err = mime_maker_new (&mime, NULL);
1351 err = mime_maker_add_header (mime, "From", addrspec);
1354 err = mime_maker_add_header (mime, "To", submission_to);
1357 err = mime_maker_add_header (mime, "Subject", "Key publishing request");
1361 /* Tell server which draft we support. */
1362 err = mime_maker_add_header (mime, "Wks-Draft-Version",
1363 STR2(WKS_DRAFT_VERSION));
1374 /* Needs a multipart/mixed with one(!) attachment. It does
1375 * not grok a non-multipart mail. */
1376 err = mime_maker_add_header (mime, "Content-Type", "multipart/mixed");
1379 err = mime_maker_add_container (mime);
1384 err = mime_maker_add_header (mime, "Content-type",
1385 "application/pgp-keys");
1389 if (es_fclose_snatch (key, &data, &datalen))
1391 err = gpg_error_from_syserror ();
1395 err = mime_maker_add_body_data (mime, data, datalen);
1402 err = mime_maker_add_header (mime, "Content-Type",
1403 "multipart/encrypted; "
1404 "protocol=\"application/pgp-encrypted\"");
1407 err = mime_maker_add_container (mime);
1411 err = mime_maker_add_header (mime, "Content-Type",
1412 "application/pgp-encrypted");
1415 err = mime_maker_add_body (mime, "Version: 1\n");
1418 err = mime_maker_add_header (mime, "Content-Type",
1419 "application/octet-stream");
1423 err = mime_maker_add_stream (mime, &keyenc);
1428 err = wks_send_mime (mime);
1431 mime_maker_release (mime);
1432 xfree (submission_to);
1433 free_uidinfo_list (uidlist);
1436 wks_free_policy (policy);
1445 encrypt_response_status_cb (void *opaque, const char *keyword, char *args)
1447 gpg_error_t *failure = opaque;
1448 const char *fields[2];
1451 log_debug ("gpg status: %s %s\n", keyword, args);
1453 if (!strcmp (keyword, "FAILURE"))
1455 if (split_fields (args, fields, DIM (fields)) >= 2
1456 && !strcmp (fields[0], "encrypt"))
1457 *failure = strtoul (fields[1], NULL, 10);
1463 /* Encrypt the INPUT stream to a new stream which is stored at success
1464 * at R_OUTPUT. Encryption is done for ADDRSPEC and for FINGERPRINT
1465 * (so that the sent message may later be inspected by the user). We
1466 * currently retrieve that key from the WKD, DANE, or from "local".
1467 * "local" is last to prefer the latest key version but use a local
1468 * copy in case we are working offline. It might be useful for the
1469 * server to send the fingerprint of its encryption key - or even the
1470 * entire key back. */
1472 encrypt_response (estream_t *r_output, estream_t input, const char *addrspec,
1473 const char *fingerprint)
1479 gpg_error_t gpg_err = 0;
1483 output = es_fopenmem (0, "w+b");
1486 err = gpg_error_from_syserror ();
1487 log_error ("error allocating memory buffer: %s\n", gpg_strerror (err));
1491 ccparray_init (&ccp, 0);
1493 ccparray_put (&ccp, "--no-options");
1494 if (opt.verbose < 2)
1495 ccparray_put (&ccp, "--quiet");
1497 ccparray_put (&ccp, "--verbose");
1498 ccparray_put (&ccp, "--batch");
1499 ccparray_put (&ccp, "--status-fd=2");
1500 ccparray_put (&ccp, "--always-trust");
1501 ccparray_put (&ccp, "--armor");
1502 ccparray_put (&ccp, "-z0"); /* No compression for improved robustness. */
1503 if (fake_submission_addr)
1504 ccparray_put (&ccp, "--auto-key-locate=clear,local");
1506 ccparray_put (&ccp, "--auto-key-locate=clear,wkd,dane,local");
1507 ccparray_put (&ccp, "--recipient");
1508 ccparray_put (&ccp, addrspec);
1509 ccparray_put (&ccp, "--recipient");
1510 ccparray_put (&ccp, fingerprint);
1511 ccparray_put (&ccp, "--encrypt");
1512 ccparray_put (&ccp, "--");
1514 ccparray_put (&ccp, NULL);
1515 argv = ccparray_get (&ccp, NULL);
1518 err = gpg_error_from_syserror ();
1521 err = gnupg_exec_tool_stream (opt.gpg_program, argv, input,
1523 encrypt_response_status_cb, &gpg_err);
1528 log_error ("encryption failed: %s\n", gpg_strerror (err));
1544 send_confirmation_response (const char *sender, const char *address,
1545 const char *nonce, int encrypt,
1546 const char *fingerprint)
1549 estream_t body = NULL;
1550 estream_t bodyenc = NULL;
1551 mime_maker_t mime = NULL;
1553 body = es_fopenmem (0, "w+b");
1556 err = gpg_error_from_syserror ();
1557 log_error ("error allocating memory buffer: %s\n", gpg_strerror (err));
1561 /* It is fine to use 8 bit encoding because that is encrypted and
1562 * only our client will see it. */
1565 es_fputs ("Content-Type: application/vnd.gnupg.wks\n"
1566 "Content-Transfer-Encoding: 8bit\n"
1571 es_fprintf (body, ("type: confirmation-response\n"
1582 err = encrypt_response (&bodyenc, body, sender, fingerprint);
1589 err = mime_maker_new (&mime, NULL);
1592 err = mime_maker_add_header (mime, "From", address);
1595 err = mime_maker_add_header (mime, "To", sender);
1598 err = mime_maker_add_header (mime, "Subject", "Key publication confirmation");
1601 err = mime_maker_add_header (mime, "Wks-Draft-Version",
1602 STR2(WKS_DRAFT_VERSION));
1608 err = mime_maker_add_header (mime, "Content-Type",
1609 "multipart/encrypted; "
1610 "protocol=\"application/pgp-encrypted\"");
1613 err = mime_maker_add_container (mime);
1617 err = mime_maker_add_header (mime, "Content-Type",
1618 "application/pgp-encrypted");
1621 err = mime_maker_add_body (mime, "Version: 1\n");
1624 err = mime_maker_add_header (mime, "Content-Type",
1625 "application/octet-stream");
1629 err = mime_maker_add_stream (mime, &bodyenc);
1635 err = mime_maker_add_header (mime, "Content-Type",
1636 "application/vnd.gnupg.wks");
1639 err = mime_maker_add_stream (mime, &body);
1644 err = wks_send_mime (mime);
1647 mime_maker_release (mime);
1648 es_fclose (bodyenc);
1654 /* Reply to a confirmation request. The MSG has already been
1655 * decrypted and we only need to send the nonce back. MAINFPR is
1656 * either NULL or the primary key fingerprint of the key used to
1657 * decrypt the request. */
1659 process_confirmation_request (estream_t msg, const char *mainfpr)
1664 const char *value, *sender, *address, *fingerprint, *nonce;
1666 err = nvc_parse (&nvc, NULL, msg);
1669 log_error ("parsing the WKS message failed: %s\n", gpg_strerror (err));
1675 log_debug ("request follows:\n");
1676 nvc_write (nvc, log_get_stream ());
1679 /* Check that this is a confirmation request. */
1680 if (!((item = nvc_lookup (nvc, "type:")) && (value = nve_value (item))
1681 && !strcmp (value, "confirmation-request")))
1684 log_error ("received unexpected wks message '%s'\n", value);
1686 log_error ("received invalid wks message: %s\n", "'type' missing");
1687 err = gpg_error (GPG_ERR_UNEXPECTED_MSG);
1691 /* Get the fingerprint. */
1692 if (!((item = nvc_lookup (nvc, "fingerprint:"))
1693 && (value = nve_value (item))
1694 && strlen (value) >= 40))
1696 log_error ("received invalid wks message: %s\n",
1697 "'fingerprint' missing or invalid");
1698 err = gpg_error (GPG_ERR_INV_DATA);
1701 fingerprint = value;
1703 /* Check that the fingerprint matches the key used to decrypt the
1704 * message. In --read mode or with the old format we don't have the
1705 * decryption key; thus we can't bail out. */
1706 if (!mainfpr || ascii_strcasecmp (mainfpr, fingerprint))
1708 log_info ("target fingerprint: %s\n", fingerprint);
1709 log_info ("but decrypted with: %s\n", mainfpr);
1710 log_error ("confirmation request not decrypted with target key\n");
1713 err = gpg_error (GPG_ERR_INV_DATA);
1718 /* Get the address. */
1719 if (!((item = nvc_lookup (nvc, "address:")) && (value = nve_value (item))
1720 && is_valid_mailbox (value)))
1722 log_error ("received invalid wks message: %s\n",
1723 "'address' missing or invalid");
1724 err = gpg_error (GPG_ERR_INV_DATA);
1728 /* FIXME: Check that the "address" matches the User ID we want to
1731 /* Get the sender. */
1732 if (!((item = nvc_lookup (nvc, "sender:")) && (value = nve_value (item))
1733 && is_valid_mailbox (value)))
1735 log_error ("received invalid wks message: %s\n",
1736 "'sender' missing or invalid");
1737 err = gpg_error (GPG_ERR_INV_DATA);
1741 /* FIXME: Check that the "sender" matches the From: address. */
1743 /* Get the nonce. */
1744 if (!((item = nvc_lookup (nvc, "nonce:")) && (value = nve_value (item))
1745 && strlen (value) > 16))
1747 log_error ("received invalid wks message: %s\n",
1748 "'nonce' missing or too short");
1749 err = gpg_error (GPG_ERR_INV_DATA);
1754 /* Send the confirmation. If no key was found, try again without
1756 err = send_confirmation_response (sender, address, nonce, 1, fingerprint);
1757 if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY)
1759 log_info ("no encryption key found - sending response in the clear\n");
1760 err = send_confirmation_response (sender, address, nonce, 0, NULL);
1769 /* Read a confirmation request and decrypt it if needed. This
1770 * function may not be used with a mail or MIME message but only with
1771 * the actual encrypted or plaintext WKS data. */
1773 read_confirmation_request (estream_t msg)
1777 estream_t plaintext = NULL;
1779 /* We take a really simple approach to check whether MSG is
1780 * encrypted: We know that an encrypted message is always armored
1781 * and thus starts with a few dashes. It is even sufficient to
1782 * check for a single dash, because that can never be a proper first
1783 * WKS data octet. We need to skip leading spaces, though. */
1784 while ((c = es_fgetc (msg)) == ' ' || c == '\t' || c == '\r' || c == '\n')
1788 log_error ("can't process an empty message\n");
1789 return gpg_error (GPG_ERR_INV_DATA);
1791 if (es_ungetc (c, msg) != c)
1793 log_error ("error ungetting octet from message\n");
1794 return gpg_error (GPG_ERR_INTERNAL);
1798 err = process_confirmation_request (msg, NULL);
1801 struct decrypt_stream_parm_s decinfo;
1803 err = decrypt_stream (&plaintext, &decinfo, msg);
1805 log_error ("decryption failed: %s\n", gpg_strerror (err));
1806 else if (decinfo.otrust != 'u')
1808 err = gpg_error (GPG_ERR_WRONG_SECKEY);
1809 log_error ("key used to decrypt the confirmation request"
1810 " was not generated by us (otrust=%c)\n", decinfo.otrust);
1813 err = process_confirmation_request (plaintext, decinfo.mainfpr);
1814 xfree (decinfo.fpr);
1815 xfree (decinfo.mainfpr);
1818 es_fclose (plaintext);
1823 /* Called from the MIME receiver to process the plain text data in MSG. */
1825 command_receive_cb (void *opaque, const char *mediatype,
1826 estream_t msg, unsigned int flags)
1833 if (!strcmp (mediatype, "application/vnd.gnupg.wks"))
1834 err = read_confirmation_request (msg);
1837 log_info ("ignoring unexpected message of type '%s'\n", mediatype);
1838 err = gpg_error (GPG_ERR_UNEXPECTED_MSG);
1846 /* An object used to communicate with the mirror_one_key callback. */
1851 unsigned int nkeys; /* Number of keys processed. */
1852 unsigned int nuids; /* Number of published user ids. */
1853 } mirror_one_key_parm;
1856 /* Return true if the Given a mail DOMAIN and the full addrspec MBOX
1859 domain_matches_mbox (const char *domain, const char *mbox)
1863 if (!domain || !mbox)
1865 s = strchr (domain, '@');
1869 return 0; /* Not a valid domain. */
1871 s = strchr (mbox, '@');
1873 return 0; /* Not a valid mbox. */
1876 return !ascii_strcasecmp (domain, mbox);
1880 /* Core of mirror_one_key with the goal of mirroring just one uid.
1881 * UIDLIST is used to figure out whether the given MBOX occurs several
1882 * times in UIDLIST and then to single out the newest one. This is
1883 * so that for a key with
1884 * uid: Joe Someone <joe@example.org>
1885 * uid: Joe <joe@example.org>
1886 * only the news user id (and thus its self-signature) is used.
1887 * UIDLIST is nodified to set all MBOX fields to NULL for a processed
1888 * user id. FPR is the fingerprint of the key.
1891 mirror_one_keys_userid (estream_t key, const char *mbox, uidinfo_list_t uidlist,
1895 uidinfo_list_t uid, thisuid, firstuid;
1897 estream_t newkey = NULL;
1899 /* Find the UID we want to use. */
1901 thisuid = firstuid = NULL;
1902 for (uid = uidlist; uid; uid = uid->next)
1904 if ((uid->flags & 1) || !uid->mbox || strcmp (uid->mbox, mbox))
1905 continue; /* Already processed or no matching mbox. */
1906 uid->flags |= 1; /* Set "processed" flag. */
1909 if (uid->created > thistime)
1911 thistime = uid->created;
1916 thisuid = firstuid; /* This is the case for a missing timestamp. */
1919 log_error ("error finding the user id for %s (%s)\n", fpr, mbox);
1920 err = gpg_error (GPG_ERR_NO_USER_ID);
1924 /* Always filter the key so that the result will be non-armored. */
1926 err = wks_filter_uid (&newkey, key, thisuid->uid, 1);
1929 log_error ("error filtering key %s: %s\n", fpr, gpg_strerror (err));
1930 err = gpg_error (GPG_ERR_NO_PUBKEY);
1936 if (es_fseek (newkey, 0, SEEK_END))
1938 err = gpg_error_from_syserror ();
1939 log_error ("error seeking stream: %s\n", gpg_strerror (err));
1942 err = wks_find_add_revocs (newkey, mbox);
1945 log_error ("error finding revocations for '%s': %s\n",
1946 mbox, gpg_strerror (err));
1952 err = wks_install_key_core (newkey, mbox);
1954 log_info ("key %s published for '%s'\n", fpr, mbox);
1955 mirror_one_key_parm.nuids++;
1956 if (!opt.quiet && !(mirror_one_key_parm.nuids % 25))
1957 log_info ("%u user ids from %d keys so far\n",
1958 mirror_one_key_parm.nuids, mirror_one_key_parm.nkeys);
1966 /* The callback used by command_mirror. It received an estream with
1967 * one key and should return success to process the next key. */
1969 mirror_one_key (estream_t key)
1971 gpg_error_t err = 0;
1973 uidinfo_list_t uidlist = NULL;
1975 const char *domain = mirror_one_key_parm.domain;
1977 /* List the key to get all user ids. */
1978 err = wks_list_key (key, &fpr, &uidlist);
1981 log_error ("error parsing a key: %s - skipped\n",
1982 gpg_strerror (err));
1983 mirror_one_key_parm.anyerror = 1;
1987 for (uid = uidlist; uid; uid = uid->next)
1989 if (!uid->mbox || (uid->flags & 1))
1990 continue; /* No mail box or already processed. */
1993 if (!domain_matches_mbox (domain, uid->mbox))
1994 continue; /* We don't want this one. */
1995 if (is_in_blacklist (uid->mbox))
1998 err = mirror_one_keys_userid (key, uid->mbox, uidlist, fpr);
2001 log_error ("error processing key %s: %s - skipped\n",
2002 fpr, gpg_strerror (err));
2003 mirror_one_key_parm.anyerror = 1;
2008 mirror_one_key_parm.nkeys++;
2012 free_uidinfo_list (uidlist);
2018 /* Copy the keys from the configured LDAP server into a local WKD.
2019 * DOMAINLIST is an array of domain names to restrict the copy to only
2020 * the given domains; if it is NULL all keys are mirrored. */
2022 command_mirror (char *domainlist[])
2026 char *domainbuf = NULL;
2028 mirror_one_key_parm.anyerror = 0;
2029 mirror_one_key_parm.nkeys = 0;
2030 mirror_one_key_parm.nuids = 0;
2034 mirror_one_key_parm.domain = "";
2035 err = wkd_dirmngr_ks_get (NULL, mirror_one_key);
2039 while ((domain = *domainlist++))
2041 if (*domain != '.' && domain[1] != '@')
2043 /* This does not already specify a mail search by
2044 * domain. Change it. */
2046 domainbuf = xstrconcat (".@", domain, NULL);
2049 mirror_one_key_parm.domain = domain;
2051 log_info ("mirroring keys for domain '%s'\n", domain+2);
2052 err = wkd_dirmngr_ks_get (domain, mirror_one_key);
2059 log_info ("a total of %u user ids from %d keys published\n",
2060 mirror_one_key_parm.nuids, mirror_one_key_parm.nkeys);
2062 log_error ("error mirroring LDAP directory: %s <%s>\n",
2063 gpg_strerror (err), gpg_strsource (err));
2064 else if (mirror_one_key_parm.anyerror)
2065 log_info ("warning: errors encountered - not all keys are mirrored\n");