Unverified Commit 142eed1a authored by Derek Nola's avatar Derek Nola Committed by GitHub

Create encryption hash file if it doesn't exist (#5140)

parent 299ca600
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
b64 "encoding/base64" b64 "encoding/base64"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net" "net"
...@@ -657,6 +658,16 @@ func genEncryptionConfigAndState(controlConfig *config.Control, runtime *config. ...@@ -657,6 +658,16 @@ func genEncryptionConfigAndState(controlConfig *config.Control, runtime *config.
return nil return nil
} }
if s, err := os.Stat(runtime.EncryptionConfig); err == nil && s.Size() > 0 { if s, err := os.Stat(runtime.EncryptionConfig); err == nil && s.Size() > 0 {
// On upgrade from older versions, the encryption hash may not exist, create it
if _, err := os.Stat(runtime.EncryptionHash); errors.Is(err, os.ErrNotExist) {
curEncryptionByte, err := ioutil.ReadFile(runtime.EncryptionConfig)
if err != nil {
return err
}
encryptionConfigHash := sha256.Sum256(curEncryptionByte)
ann := "start-" + hex.EncodeToString(encryptionConfigHash[:])
return ioutil.WriteFile(controlConfig.Runtime.EncryptionHash, []byte(ann), 0600)
}
return nil return nil
} }
......
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