summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-29 18:15:17 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-29 18:15:17 +0000
commitd4d323b04e9eef2416b1a49f6cf1be1cc5c511fc (patch)
tree3f18b55553f09055fb280376be7089100a6a3dc3 /src/main.c
parent87c90bd928e494ebd5d7f9db3386f6fc46211c43 (diff)
downloadrspamd-d4d323b04e9eef2416b1a49f6cf1be1cc5c511fc.tar.gz
rspamd-d4d323b04e9eef2416b1a49f6cf1be1cc5c511fc.zip
Allow generate keypairs by rspamd.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c18
1 files changed, 18 insertions, 0 deletions
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);