1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

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!
This commit is contained in:
Alberto Bertogli
2016-11-22 20:39:19 +00:00
parent 170aaaf490
commit 7b51ce725b

View File

@@ -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
}