Slide 19
Slide 19 text
PARSING A TLS CLIENT HELLO — RECAP
03. PARSING TLS
conn.SetDeadline(time.Now().Add(30 * time.Second))
var buf bytes.Buffer
if _, err := io.CopyN(&buf, conn, 1+2+2); err != nil {
return
}
length := binary.BigEndian.Uint16(buf.Bytes()[3:5])
if _, err := io.CopyN(&buf, conn, int64(length));
err != nil {
return
}
Set a timeout and
read the message.
ch, ok := ParseClientHello(buf.Bytes())
if ok {
log.Printf("Received connection for %q!", ch.SNI)
}
Parse TLS.