gemexp: add -R to generate an RSA (4096) key instead of an EC one (default)

This commit is contained in:
Omar Polo 2023-10-18 18:06:08 +00:00
parent adaae5163c
commit bab32701fb
2 changed files with 12 additions and 5 deletions

11
ge.c
View File

@ -32,6 +32,8 @@
#include "log.h"
static int gen_eckey = 1;
int privsep_process;
static const struct option opts[] = {
@ -100,7 +102,7 @@ load_local_cert(struct vhost *h, const char *hostname, const char *dir)
fatal("asprintf");
if (access(cert, R_OK) == -1 || access(key, R_OK) == -1)
gencert(hostname, cert, key, 1);
gencert(hostname, cert, key, gen_eckey);
h->cert = tls_load_file(cert, &h->certlen, NULL);
if (h->cert == NULL)
@ -248,7 +250,7 @@ usage(void)
{
fprintf(stderr,
"Version: " GE_STRING "\n"
"Usage: %s [-hV] [-d certs-dir] [-H hostname] [-p port] [dir]\n",
"Usage: %s [-hRV] [-d certs-dir] [-H hostname] [-p port] [dir]\n",
getprogname());
exit(1);
}
@ -272,7 +274,7 @@ main(int argc, char **argv)
/* ge doesn't do privsep so no privsep crypto engine. */
conf->use_privsep_crypto = 0;
while ((ch = getopt_long(argc, argv, "d:H:hp:V", opts, NULL)) != -1) {
while ((ch = getopt_long(argc, argv, "d:H:hp:RV", opts, NULL)) != -1) {
switch (ch) {
case 'd':
certs_dir = optarg;
@ -289,6 +291,9 @@ main(int argc, char **argv)
fatalx("port number is %s: %s", errstr,
optarg);
break;
case 'R':
gen_eckey = 0;
break;
case 'V':
puts("Version: " GE_STRING);
return 0;

View File

@ -11,7 +11,7 @@
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.Dd August 29, 2023
.Dd October 18, 2023
.Dt GEMEXP 1
.Os
.Sh NAME
@ -20,7 +20,7 @@
.Sh SYNOPSIS
.Nm
.Bk -words
.Op Fl hV
.Op Fl hRV
.Op Fl d Ar certs-dir
.Op Fl H Ar hostname
.Op Fl p Ar port
@ -65,6 +65,8 @@ and are implicitly generated if not found.
Print the usage and exit.
.It Fl p Ar port
The port to bind to, 1965 by default.
.It Fl R
Generate an RSA key instead of an EC one.
.It Fl V , Fl -version
Print the version and exit.
.It Ar directory