Skip to content

Commit

Permalink
node: add info message when JWT secret is loaded (ethereum#25095)
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Lange <[email protected]>
  • Loading branch information
2 people authored and blakehhuynh committed Oct 7, 2022
1 parent ea4df95 commit d276a9a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
crand "crypto/rand"
"errors"
"fmt"
"hash/crc32"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -352,10 +353,10 @@ func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) {
fileName = n.ResolvePath(datadirJWTKey)
}
// try reading from file
log.Debug("Reading JWT secret", "path", fileName)
if data, err := os.ReadFile(fileName); err == nil {
jwtSecret := common.FromHex(strings.TrimSpace(string(data)))
if len(jwtSecret) == 32 {
log.Info("Loaded JWT secret file", "path", fileName, "crc32", fmt.Sprintf("%#x", crc32.ChecksumIEEE(jwtSecret)))
return jwtSecret, nil
}
log.Error("Invalid JWT secret", "path", fileName, "length", len(jwtSecret))
Expand Down

0 comments on commit d276a9a

Please sign in to comment.