summary refs log tree commit diff
path: root/bounce.c
diff options
context:
space:
mode:
Diffstat (limited to 'bounce.c')
-rw-r--r--bounce.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/bounce.c b/bounce.c
index 8b9ea11..2da86bc 100644
--- a/bounce.c
+++ b/bounce.c
@@ -72,15 +72,15 @@ static void hashPass(void) {
 	printf("%s\n", crypt(pass, salt));
 }
 
-static void genKey(const char *path) {
+static void genReq(const char *path) {
 	const char *name = strrchr(path, '/');
 	name = (name ? &name[1] : path);
 	char subj[256];
 	snprintf(subj, sizeof(subj), "/CN=%.*s", (int)strcspn(name, "."), name);
 	execlp(
 		OPENSSL_BIN, "openssl", "req",
-		"-x509", "-new", "-newkey", "rsa:4096", "-sha256", "-days", "3650",
-		"-nodes", "-subj", subj, "-keyout", path,
+		"-new", "-newkey", "rsa:4096", "-sha256", "-nodes",
+		"-subj", subj, "-keyout", path,
 		NULL
 	);
 	err(EX_UNAVAILABLE, "openssl");
@@ -96,12 +96,6 @@ static void genCert(const char *path, const char *ca) {
 	int out = open(path, O_WRONLY | O_APPEND | O_CREAT, 0600);
 	if (out < 0) err(EX_CANTCREAT, "%s", path);
 
-	redir(STDOUT_FILENO, out);
-	if (!ca) {
-		genKey(path);
-		return;
-	}
-
 	int rw[2];
 	int error = pipe(rw);
 	if (error) err(EX_OSERR, "pipe");
@@ -111,14 +105,16 @@ static void genCert(const char *path, const char *ca) {
 	if (!pid) {
 		close(rw[0]);
 		redir(STDOUT_FILENO, rw[1]);
-		genKey(path);
+		genReq(path);
 	}
 
 	close(rw[1]);
 	redir(STDIN_FILENO, rw[0]);
+	redir(STDOUT_FILENO, out);
 	execlp(
 		OPENSSL_BIN, "openssl", "x509",
-		"-CA", ca, "-CAcreateserial", "-days", "3650",
+		"-req", "-days", "3650", "-CAcreateserial",
+		(ca ? "-CA" : "-signkey"), (ca ? ca : path),
 		NULL
 	);
 	err(EX_UNAVAILABLE, "openssl");
2020-10-07 17:22:13 -0400'>2020-10-07Use mandoc -T utf8 for text.June McEnroe 2020-09-20Add The Awakened KingdomJune McEnroe 2020-09-12Move /opt/local back, cheat port select to use system manJune McEnroe 2020-09-12Move /opt/local behind /usr againJune McEnroe 2020-09-12Enable toc in cgit renderings of man pagesJune McEnroe 2020-09-11Install mandoc on macOSJune McEnroe 2020-09-11Rewrite install script yet againJune McEnroe 2020-09-11Remove NetBSD from install scriptJune McEnroe 2020-09-11Use MacPorts rather than pkgsrcJune McEnroe 2020-09-11Add debian VM name to sshJune McEnroe 2020-09-11Add influencer tweetJune McEnroe 2020-09-10Add The Kingdom of GodsJune McEnroe 2020-09-07Add SunglassesJune McEnroe 2020-09-06Add Between the BreathsJune McEnroe 2020-09-04Open /dev/tty in nudgeJune McEnroe 2020-09-04Add nudgeJune McEnroe 2020-09-03Build fbclock with -lzJune McEnroe 2020-08-29Add tweets from retweetsJune McEnroe2020-02-04Refactor and rebuild to TypeScriptdestruc7i0n 2019-02-11Local file supportdestruc7i0n 2018-11-11Let's make this usable again!destruc7i0n 2018-02-23Allow configurable discord formatArcensoth 2018-02-23Revert example tellraw format to mimic the originalArcensoth 2018-02-23Update readme with new tellraw config optionArcensoth 2018-02-23Allow configurable tellraw formatArcensoth 2018-02-23Allow config file to be passed as a parameterArcensoth