Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
add a function to initialize session ticket keys in a Config
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jun 24, 2023
1 parent fea6306 commit 8ae6b8e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions unsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ func compareStruct(a, b reflect.Type) bool {
}
return true
}

// InitSessionTicketKeys triggers the initialization of session ticket keys.
func InitSessionTicketKeys(conf *Config) {
fromConfig(conf).ticketKeys(nil)
}
14 changes: 14 additions & 0 deletions unsafe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,17 @@ func TestClientSessionStateReinterpretCast(t *testing.T) {
// t.Fatal("failed")
// }
// }

func TestInitSessionTicketKeys(t *testing.T) {
c1 := testConfig.Clone()
InitSessionTicketKeys(c1)
c2 := c1.Clone()

stk := fromConfig(c1).autoSessionTicketKeys
if len(stk) == 0 {
t.Fatal("no session ticket keys")
}
if !reflect.DeepEqual(stk, fromConfig(c2).autoSessionTicketKeys) {
t.Fatal("session ticket keys don't match")
}
}

0 comments on commit 8ae6b8e

Please sign in to comment.