Added save/load to tls state

graph-rework-2
noah metz 2023-07-21 01:11:59 -06:00
parent cf248ee5b0
commit 2c1c75572e
1 changed files with 5 additions and 1 deletions

@ -641,6 +641,8 @@ type GQLThreadJSON struct {
Users []string `json:"users"` Users []string `json:"users"`
Key []byte `json:"key"` Key []byte `json:"key"`
ECDH uint8 `json:"ecdh_curve"` ECDH uint8 `json:"ecdh_curve"`
SSLKey []byte `json:"ssl_key"`
SSLCert []byte `json:"ssl_cert"`
} }
var ecdsa_curves = map[uint8]elliptic.Curve{ var ecdsa_curves = map[uint8]elliptic.Curve{
@ -680,6 +682,8 @@ func NewGQLThreadJSON(thread *GQLThread) GQLThreadJSON {
Users: users, Users: users,
Key: ser_key, Key: ser_key,
ECDH: ecdh_curve_ids[thread.ECDH], ECDH: ecdh_curve_ids[thread.ECDH],
SSLKey: thread.ssl_key,
SSLCert: thread.ssl_cert,
} }
} }
@ -700,7 +704,7 @@ func LoadGQLThread(ctx *Context, id NodeID, data []byte, nodes NodeMap) (Node, e
return nil, err return nil, err
} }
thread := NewGQLThread(id, j.Name, j.StateName, j.Listen, ecdh_curve, key, nil, nil) thread := NewGQLThread(id, j.Name, j.StateName, j.Listen, ecdh_curve, key, j.SSLCert, j.SSLKey)
thread.Users = map[NodeID]*User{} thread.Users = map[NodeID]*User{}
for _, id_str := range(j.Users) { for _, id_str := range(j.Users) {
id, err := ParseID(id_str) id, err := ParseID(id_str)