author | Alberto Bertogli
<albertito@blitiri.com.ar> 2023-09-02 12:54:17 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2023-09-02 12:58:24 UTC |
parent | 47535651d203cba7434fcafc1c07394731aa5a4b |
chasquid.go | +8 | -4 |
test/t-01-simple_local/config/certs/symlink | +1 | -0 |
diff --git a/chasquid.go b/chasquid.go index 35aa99b..1bd7356 100644 --- a/chasquid.go +++ b/chasquid.go @@ -92,8 +92,8 @@ func main() { // The structure matches letsencrypt's, to make it easier for that case. log.Infof("Loading certificates") for _, info := range mustReadDir("certs/") { - if !info.IsDir() { - // Skip non-directories. + if info.Type().IsRegular() { + // Ignore regular files, we only care about directories. continue } @@ -101,12 +101,16 @@ func main() { dir := filepath.Join("certs/", name) log.Infof(" %s", name) + // Ignore directories that don't have both keys. + // We warn about this because it can be hard to debug otherwise. certPath := filepath.Join(dir, "fullchain.pem") - if _, err := os.Stat(certPath); os.IsNotExist(err) { + if _, err := os.Stat(certPath); err != nil { + log.Infof(" skipping: %v", err) continue } keyPath := filepath.Join(dir, "privkey.pem") - if _, err := os.Stat(keyPath); os.IsNotExist(err) { + if _, err := os.Stat(keyPath); err != nil { + log.Infof(" skipping: %v", err) continue } diff --git a/test/t-01-simple_local/config/certs/symlink b/test/t-01-simple_local/config/certs/symlink new file mode 120000 index 0000000..13b59f7 --- /dev/null +++ b/test/t-01-simple_local/config/certs/symlink @@ -0,0 +1 @@ +testserver/ \ No newline at end of file