From 7b51ce725bd5a053dec0a2b19b9d8313eaa87279 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Tue, 22 Nov 2016 20:39:19 +0000 Subject: [PATCH] chasquid: Ignore non-directories in certs/ We only care about directories within the certs/, but the code as-is complains if there are files. This patch makes the iteration skip non-directories entirely. Thanks to Martin Ferrari for the bug report! --- chasquid.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chasquid.go b/chasquid.go index 2b009d4..80fb3af 100644 --- a/chasquid.go +++ b/chasquid.go @@ -94,13 +94,19 @@ func main() { log.Infof("Loading certificates") for _, info := range mustReadDir("certs/") { name := info.Name() + dir := filepath.Join("certs/", name) + if fi, err := os.Stat(dir); err == nil && !fi.IsDir() { + // Skip non-directories. + continue + } + log.Infof(" %s", name) - certPath := filepath.Join("certs/", name, "fullchain.pem") + certPath := filepath.Join(dir, "fullchain.pem") if _, err := os.Stat(certPath); os.IsNotExist(err) { continue } - keyPath := filepath.Join("certs/", name, "privkey.pem") + keyPath := filepath.Join(dir, "privkey.pem") if _, err := os.Stat(keyPath); os.IsNotExist(err) { continue }