3 ms·
>One hasty bugfix to clear the buffers after establishing TLS Discarding bytes seems like the wrong thing to do as well. If your starttls just takes the socket
by knome 4y ago
>One hasty bugfix to clear the buffers after establishing TLS
Discarding bytes seems like the wrong thing to do as well. If your starttls just takes the socket and no "initial bytes", as I would expect, you would need to either read off the socket a byte at a time til then or better to use MSG_PEEK to not read past the next \r\n.
- billpg 4y agoI thought about that but I didn't want to be stuffing bytes back into the incoming stream and I didn't want to be reading the stream byte-by-byte either unless I really had to. I had a nice bit of code that read blocks of bytes and looked for the CRLF separating lines - even handling the case where the CR is one block and the LF is in the next one - and I didn't want to dismantle that. I read the relevant RFC and there was a clear exception to the rules of PIPELINING that meant a conforming client doesn't send the "ClientHello" until the server has responded to the STLS command. I felt justified in clearing the buffer at that point.