Let the server send a mock encrypted certificate after ChangeCipherSuite to imitate real behaviour more closely

This commit is contained in:
Qian Wang 2019-08-07 00:28:08 +01:00
parent 81f233c226
commit ae4fc917b6
2 changed files with 10 additions and 3 deletions

View File

@ -66,9 +66,12 @@ func PrepareConnection(sta *State, conn net.Conn) (sessionKey []byte, err error)
return return
} }
_, err = util.ReadTLS(conn, buf) for i := 0; i < 2; i++ {
if err != nil { // ChangeCipherSpec and EncryptedCert (in the format of application data)
return _, err = util.ReadTLS(conn, buf)
if err != nil {
return
}
} }
return sessionKey, nil return sessionKey, nil

View File

@ -212,7 +212,11 @@ func composeReply(ch *ClientHello, sharedSecret []byte, sessionKey []byte) ([]by
} }
shBytes := addRecordLayer(sh, []byte{0x16}, TLS12) shBytes := addRecordLayer(sh, []byte{0x16}, TLS12)
ccsBytes := addRecordLayer([]byte{0x01}, []byte{0x14}, TLS12) ccsBytes := addRecordLayer([]byte{0x01}, []byte{0x14}, TLS12)
cert := make([]byte, 68) // this is always 68 bytes
rand.Read(cert)
encryptedCertBytes := addRecordLayer(cert, []byte{0x17}, TLS12)
ret := append(shBytes, ccsBytes...) ret := append(shBytes, ccsBytes...)
ret = append(ret, encryptedCertBytes...)
return ret, nil return ret, nil
} }