Fix certificates not loading when key file exists

This commit is contained in:
Melon 2023-07-16 21:17:15 +01:00
parent dcef716d8f
commit 8ab677964d
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 8 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import (
"io/fs"
"log"
"math/big"
"os"
"strings"
"sync"
"sync/atomic"
@ -172,6 +173,10 @@ func (c *Certs) internalCompile(m map[string]*tls.Certificate) error {
// try to read key file
keyData, err := fs.ReadFile(c.kDir, keyName)
if err != nil {
// ignore the file if the certificate doesn't exist
if os.IsNotExist(err) {
continue
}
return fmt.Errorf("failed to read key file '%s': %w", keyName, err)
}

View File

@ -59,8 +59,8 @@ func (s *serveCmd) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{
return subcommands.ExitFailure
}
var conf startUpConfig
err = json.NewDecoder(openConf).Decode(&conf)
var config startUpConfig
err = json.NewDecoder(openConf).Decode(&config)
if err != nil {
log.Println("[Violet] Error: invalid config file: ", err)
return subcommands.ExitFailure
@ -68,7 +68,7 @@ func (s *serveCmd) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{
// working directory is the parent of the config file
wd := filepath.Dir(s.configPath)
normalLoad(conf, wd)
normalLoad(config, wd)
return subcommands.ExitSuccess
}