]> source.dussan.org Git - rspamd.git/commitdiff
Allow generate keypairs by rspamd.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Jan 2015 18:15:17 +0000 (18:15 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 29 Jan 2015 18:15:17 +0000 (18:15 +0000)
src/libutil/http.c
src/main.c

index 9a473893203ca9a893c6bf051620f44665efa3f5..78edc7d1a157475ec9a08e0944abcc901bf95bfd 100644 (file)
@@ -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");
        }
 
index da17018f6895da22952eba6b0b3adfbe2cae88c8..5b4505bb083b61bb94216f701c3af00c0cfd78a1 100644 (file)
@@ -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);