]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: haterm: provide -b and -c options (RSA key size, ECDSA curves)
authorFrederic Lecaille <flecaille@haproxy.com>
Fri, 20 Feb 2026 09:40:04 +0000 (10:40 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 20 Feb 2026 09:43:54 +0000 (10:43 +0100)
Add -b and -c options to the haterm argv parser. Use -b to specify the RSA
private key size (in bits) and -c to define the ECDSA certificate curves.
These self-signed certificates are required for haterm SSL bindings.

doc/haterm.txt
src/haterm_init.c

index fbc58b9ee703776188aef78b11e83da5ebed4c06..c84b2368206f0d6ee9b55286477fb1c85715ea2a 100644 (file)
@@ -58,6 +58,8 @@ versions. It displays its usage when run without argument or wrong arguments:
         -T <line> : multiple option; append <line> to the "traces" section
         -C : dump the configuration and exit
         -D : goes daemon
+        -b <keysize> : RSA key size in bits (ex: "2048", "4096"...)
+        -c <curves> : ECSDA curves (ex: "P-256", "P-384"...)
         -v : shows version
         -d : enable the traces for all http protocols
 
index b59ce170f364638cf7edc6cd322a75fa7d7ad674..61679e7fa3f68ea48320820718acc09de356aaa3 100644 (file)
@@ -20,6 +20,8 @@ static void haterm_usage(char *name)
                "        -T <line> : multiple option; append <line> to the \"traces\" section\n"
                "        -C : dump the configuration and exit\n"
                "        -D : goes daemon\n"
+               "        -b <keysize> : RSA key size in bits (ex: \"2048\", \"4096\"...)\n"
+               "        -c <curves> : ECSDA curves (ex: \"P-256\", \"P-384\"...)\n"
                "        -v : shows version\n"
                "        -d : enable the traces for all http protocols\n", name);
        exit(1);
@@ -34,10 +36,10 @@ static const char *haterm_cfg_dflt_str =
             "\tmode haterm\n"
             "\ttimeout client 25s\n";
 
-static const char *haterm_cfg_crt_store_str =
-        "crt-store\n"
-            "\tload generate-dummy on keytype RSA crt "   HATERM_RSA_CERT_NAME   "\n"
-            "\tload generate-dummy on keytype ECDSA crt " HATERM_ECDSA_CERT_NAME "\n";
+#define HATERM_CFG_CRT_STORE_STR_FMT \
+        "crt-store\n" \
+            "\tload generate-dummy on keytype RSA bits %s crt "     HATERM_RSA_CERT_NAME   "\n" \
+            "\tload generate-dummy on keytype ECDSA curves %s crt " HATERM_ECDSA_CERT_NAME "\n\n"
 
 static const char *haterm_cfg_traces_str =
         "traces\n"
@@ -159,6 +161,7 @@ void haproxy_init_args(int argc, char **argv)
        struct hbuf mbuf = HBUF_NULL; // to build the main of the cfgfile
        struct hbuf fbuf = HBUF_NULL; // "frontend" section
        struct hbuf tbuf = HBUF_NULL; // "traces" section
+       char *bits = NULL, *curves = NULL;
 
        fileless_mode = 1;
        if (argc <= 1)
@@ -206,6 +209,20 @@ void haproxy_init_args(int argc, char **argv)
                                printf("HATerm version " HAPROXY_VERSION " released " HAPROXY_DATE "\n");
                                exit(0);
                        }
+                       else if (*opt == 'b') {
+                               argv++; argc--;
+                               if (argc <= 0 || **argv == '-')
+                                       haterm_usage(progname);
+
+                               bits = *argv;
+                       }
+                       else if (*opt == 'c') {
+                               argv++; argc--;
+                               if (argc <= 0 || **argv == '-')
+                                       haterm_usage(progname);
+
+                               curves = *argv;
+                       }
                        else if (*opt == 'F') {
                                argv++; argc--;
                                if (argc <= 0 || **argv == '-')
@@ -354,7 +371,8 @@ void haproxy_init_args(int argc, char **argv)
 
        /* "crt-store" section */
        if (has_ssl)
-               hbuf_appendf(&mbuf, "%s\n", haterm_cfg_crt_store_str);
+               hbuf_appendf(&mbuf, HATERM_CFG_CRT_STORE_STR_FMT,
+                            bits ? bits : "2048", curves ? curves : "P-384");
 
        /* "frontend" section */
        hbuf_appendf(&mbuf, "%.*s\n", (int)fbuf.data, fbuf.area);