mirror of
https://github.com/1f349/violet.git
synced 2024-11-21 19:01:39 +00:00
Fix certificates not loading when key file exists
This commit is contained in:
parent
dcef716d8f
commit
8ab677964d
@ -10,6 +10,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -172,6 +173,10 @@ func (c *Certs) internalCompile(m map[string]*tls.Certificate) error {
|
|||||||
// try to read key file
|
// try to read key file
|
||||||
keyData, err := fs.ReadFile(c.kDir, keyName)
|
keyData, err := fs.ReadFile(c.kDir, keyName)
|
||||||
if err != nil {
|
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)
|
return fmt.Errorf("failed to read key file '%s': %w", keyName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ func (s *serveCmd) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{
|
|||||||
return subcommands.ExitFailure
|
return subcommands.ExitFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
var conf startUpConfig
|
var config startUpConfig
|
||||||
err = json.NewDecoder(openConf).Decode(&conf)
|
err = json.NewDecoder(openConf).Decode(&config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("[Violet] Error: invalid config file: ", err)
|
log.Println("[Violet] Error: invalid config file: ", err)
|
||||||
return subcommands.ExitFailure
|
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
|
// working directory is the parent of the config file
|
||||||
wd := filepath.Dir(s.configPath)
|
wd := filepath.Dir(s.configPath)
|
||||||
normalLoad(conf, wd)
|
normalLoad(config, wd)
|
||||||
return subcommands.ExitSuccess
|
return subcommands.ExitSuccess
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user