From: Vsevolod Stakhov Date: Thu, 29 Jan 2015 18:15:17 +0000 (+0000) Subject: Allow generate keypairs by rspamd. X-Git-Tag: 0.9.0~813 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d4d323b04e9eef2416b1a49f6cf1be1cc5c511fc;p=rspamd.git Allow generate keypairs by rspamd. --- diff --git a/src/libutil/http.c b/src/libutil/http.c index 9a4738932..78edc7d1a 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1740,7 +1740,7 @@ rspamd_http_connection_print_key (gpointer key, guint how) "Private key"); } if ((how & RSPAMD_KEYPAIR_ID)) { - rspamd_http_print_key_component (kp->sk, sizeof (kp->sk), res, how, + rspamd_http_print_key_component (kp->id, sizeof (kp->id), res, how, "Key ID"); } diff --git a/src/main.c b/src/main.c index da17018f6..5b4505bb0 100644 --- a/src/main.c +++ b/src/main.c @@ -82,6 +82,7 @@ static gchar *rspamd_pidfile = NULL; static gboolean dump_cache = FALSE; static gboolean is_debug = FALSE; static gboolean is_insecure = FALSE; +static gboolean gen_keypair = FALSE; /* List of workers that are pending to start */ static GList *workers_pending = NULL; @@ -125,6 +126,8 @@ static GOptionEntry entries[] = "Specify config file(s) to sign", NULL }, { "private-key", 0, 0, G_OPTION_ARG_FILENAME, &privkey, "Specify private key to sign", NULL }, + { "gen-keypair", 0, 0, G_OPTION_ARG_NONE, &gen_keypair, "Generate new encryption " + "keypair", NULL}, { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } }; @@ -1177,6 +1180,8 @@ main (gint argc, gchar **argv, gchar **env) GList *l; worker_t **pworker; GQuark type; + gpointer keypair; + GString *keypair_out; #ifdef HAVE_SA_SIGINFO signals_info = g_queue_new (); @@ -1245,6 +1250,19 @@ main (gint argc, gchar **argv, gchar **env) exit (perform_configs_sign ()); } + /* Same for keypair creation */ + if (gen_keypair) { + keypair = rspamd_http_connection_gen_key (); + if (keypair == NULL) { + exit (EXIT_FAILURE); + } + keypair_out = rspamd_http_connection_print_key (keypair, + RSPAMD_KEYPAIR_PUBKEY|RSPAMD_KEYPAIR_PRIVKEY|RSPAMD_KEYPAIR_ID| + RSPAMD_KEYPAIR_BASE32|RSPAMD_KEYPAIR_HUMAN); + rspamd_printf ("%V", keypair_out); + exit (EXIT_SUCCESS); + } + /* Load config */ if (!load_rspamd_config (rspamd_main->cfg, TRUE)) { exit (EXIT_FAILURE);