Unverified Commit d78d302f authored by Marius van der Wijden's avatar Marius van der Wijden Committed by GitHub

node: add info message when JWT secret is loaded (#25095)

Co-authored-by: 's avatarFelix Lange <fjl@twurst.com>
parent d8f96381
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
crand "crypto/rand" crand "crypto/rand"
"errors" "errors"
"fmt" "fmt"
"hash/crc32"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
...@@ -352,10 +353,10 @@ func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) { ...@@ -352,10 +353,10 @@ func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) {
fileName = n.ResolvePath(datadirJWTKey) fileName = n.ResolvePath(datadirJWTKey)
} }
// try reading from file // try reading from file
log.Debug("Reading JWT secret", "path", fileName)
if data, err := os.ReadFile(fileName); err == nil { if data, err := os.ReadFile(fileName); err == nil {
jwtSecret := common.FromHex(strings.TrimSpace(string(data))) jwtSecret := common.FromHex(strings.TrimSpace(string(data)))
if len(jwtSecret) == 32 { if len(jwtSecret) == 32 {
log.Info("Loaded JWT secret file", "path", fileName, "crc32", fmt.Sprintf("%#x", crc32.ChecksumIEEE(jwtSecret)))
return jwtSecret, nil return jwtSecret, nil
} }
log.Error("Invalid JWT secret", "path", fileName, "length", len(jwtSecret)) log.Error("Invalid JWT secret", "path", fileName, "length", len(jwtSecret))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment