mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 13:21:37 +00:00
parent
c145287e87
commit
47dae16a40
1 changed files with 2 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
crand "crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash/crc32"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -360,10 +361,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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue