about summary refs log tree commit diff
diff options
context:
space:
mode:
authorC. McEnroe <june@causal.agency>2020-08-20 22:00:56 -0400
committerC. McEnroe <june@causal.agency>2020-08-20 22:20:30 -0400
commit820c3850ea50a0c6bf0808fd8b2e8b83dc37f1dc (patch)
treee2b511ff8dd4065e9f73b8e1a0b8b2014e3a7318
parentUse dataPath for dbFind (diff)
downloadlitterbox-820c3850ea50a0c6bf0808fd8b2e8b83dc37f1dc.tar.gz
litterbox-820c3850ea50a0c6bf0808fd8b2e8b83dc37f1dc.zip
Use configPath to load cert/priv
-rw-r--r--litterbox.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/litterbox.c b/litterbox.c
index 1546cd8..72df0c4 100644
--- a/litterbox.c
+++ b/litterbox.c
@@ -28,6 +28,7 @@
 #include <assert.h>
 #include <err.h>
 #include <getopt.h>
+#include <limits.h>
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -857,14 +858,27 @@ int main(int argc, char *argv[]) {
 		tls_config_insecure_noverifyname(config);
 	}
 
+	const char *dirs;
+	char pbuf[PATH_MAX];
 	if (cert) {
-		error = tls_config_set_keypair_file(config, cert, (priv ? priv : cert));
-		if (error) {
-			errx(
-				EX_SOFTWARE, "tls_config_set_keypair_file: %s",
-				tls_config_error(config)
-			);
+		dirs = NULL;
+		while (NULL != (path = configPath(pbuf, sizeof(pbuf), &dirs, cert))) {
+			if (priv) {
+				error = tls_config_set_cert_file(config, path);
+			} else {
+				error = tls_config_set_keypair_file(config, path, path);
+			}
+			if (!error) break;
+		}
+		if (error) errx(EX_NOINPUT, "%s: %s", cert, tls_config_error(config));
+	}
+	if (priv) {
+		dirs = NULL;
+		while (NULL != (path = configPath(pbuf, sizeof(pbuf), &dirs, priv))) {
+			error = tls_config_set_key_file(config, path);
+			if (!error) break;
 		}
+		if (error) errx(EX_NOINPUT, "%s: %s", priv, tls_config_error(config));
 	}
 
 	error = tls_configure(client, config);