diff --git a/handshake/crypto_setup_client.go b/handshake/crypto_setup_client.go index a51a2305f..d0fcc8e81 100644 --- a/handshake/crypto_setup_client.go +++ b/handshake/crypto_setup_client.go @@ -26,6 +26,7 @@ type cryptoSetupClient struct { sno []byte nonc []byte diversificationNonce []byte + lastSentCHLO []byte certManager *crypto.CertManager } @@ -168,6 +169,9 @@ func (h *cryptoSetupClient) sendCHLO() error { if err != nil { return err } + + h.lastSentCHLO = b.Bytes() + return nil } diff --git a/handshake/crypto_setup_client_test.go b/handshake/crypto_setup_client_test.go index e10c736e2..120992220 100644 --- a/handshake/crypto_setup_client_test.go +++ b/handshake/crypto_setup_client_test.go @@ -122,6 +122,21 @@ var _ = Describe("Crypto setup", func() { Expect(cs.cryptoStream.(*mockStream).dataWritten.Len()).To(BeNumerically(">", protocol.ClientHelloMinimumSize)) }) + It("saves the last sent CHLO", func() { + // send first CHLO + err := cs.sendCHLO() + Expect(err).ToNot(HaveOccurred()) + Expect(cs.cryptoStream.(*mockStream).dataWritten.Bytes()).To(Equal(cs.lastSentCHLO)) + cs.cryptoStream.(*mockStream).dataWritten.Reset() + firstCHLO := cs.lastSentCHLO + // send second CHLO + cs.sno = []byte("foobar") + err = cs.sendCHLO() + Expect(err).ToNot(HaveOccurred()) + Expect(cs.cryptoStream.(*mockStream).dataWritten.Bytes()).To(Equal(cs.lastSentCHLO)) + Expect(cs.lastSentCHLO).ToNot(Equal(firstCHLO)) + }) + It("has the right values for an inchoate CHLO", func() { tags := cs.getTags() Expect(tags).To(HaveKey(TagSNI))