我目前正在尝试将 tls 握手实现到我正在编写的 http 代理中。我知道我可以使用 OpenSSL 为我完成这项工作,但我有兴趣自己编写它。
我目前正在研究 TLS RFC,对如何解析 ClientHello 消息感到困惑,尤其是它可能有也可能没有 session ID,而且似乎没有计算密码套件的数量或压缩方法。
有谁知道最好的方法吗?
最佳答案
session_id 前面有长度。与密码套件和压缩算法相同。
您缺少的是 RFC 的第 4.3 节:
Variable length vectors are defined by specifying a subrange of legal lengths, inclusively, using the notation . When encoded, the actual length precedes the vector's contents in the byte stream. The length will be in the form of a number consuming as many bytes as required to hold the vector's specified maximum (ceiling) length. A variable length vector with an actual length field of zero is referred to as an empty vector.
关于c++ - TLS 握手消息解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7786507/