From 1ce599d2ae68285426e251031cb98a87cb530ff6 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 9 Jul 2023 14:15:23 +0200 Subject: [PATCH] Fix handling of empty cacert environment variable This resulted in a "empty filename for root certificate supplied" error. --- cmd/restic/global.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/restic/global.go b/cmd/restic/global.go index 487fa9673..07412925e 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -151,7 +151,9 @@ func init() { globalOptions.PasswordFile = os.Getenv("RESTIC_PASSWORD_FILE") globalOptions.KeyHint = os.Getenv("RESTIC_KEY_HINT") globalOptions.PasswordCommand = os.Getenv("RESTIC_PASSWORD_COMMAND") - globalOptions.RootCertFilenames = strings.Split(os.Getenv("RESTIC_CACERT"), ",") + if os.Getenv("RESTIC_CACERT") != "" { + globalOptions.RootCertFilenames = strings.Split(os.Getenv("RESTIC_CACERT"), ",") + } globalOptions.TLSClientCertKeyFilename = os.Getenv("RESTIC_TLS_CLIENT_CERT") comp := os.Getenv("RESTIC_COMPRESSION") if comp != "" {