read connection parameters when receiving a SHLO

This commit is contained in:
Marten Seemann
2016-12-21 15:53:11 +07:00
parent a587af079d
commit 53706049c7
2 changed files with 18 additions and 0 deletions

View File

@@ -226,6 +226,11 @@ func (h *cryptoSetupClient) handleSHLOMessage(cryptoData map[Tag][]byte) error {
return err
}
err = h.connectionParameters.SetFromMap(cryptoData)
if err != nil {
return qerr.InvalidCryptoMessageParameter
}
h.aeadChanged <- struct{}{}
return nil

View File

@@ -385,6 +385,19 @@ var _ = Describe("Crypto setup", func() {
Expect(cs.HandshakeComplete()).To(BeTrue())
Expect(cs.aeadChanged).To(Receive())
})
It("reads the connection paramaters", func() {
tagMap[TagICSL] = []byte{3, 0, 0, 0} // 3 seconds
err := cs.handleSHLOMessage(tagMap)
Expect(err).ToNot(HaveOccurred())
Expect(cs.connectionParameters.GetIdleConnectionStateLifetime()).To(Equal(3 * time.Second))
})
It("errors if it can't read a connection parameter", func() {
tagMap[TagICSL] = []byte{3, 0, 0} // 1 byte too short
err := cs.handleSHLOMessage(tagMap)
Expect(err).To(MatchError(qerr.InvalidCryptoMessageParameter))
})
})
Context("CHLO generation", func() {