我的任务是从 HTTPS 消息中解析服务器名称。我被要求从“client hello”扩展以及“certicate”、“commonname”字段中解析它。
“证书”消息中有多个证书。例如,当使用 https 打开 google 并通过 wireshark 收听时,我看到 2 个证书第一个具有通用名“*.google.com”,第二个具有通用名“Google internet authority”。第一个是我连接的服务器名称,第二个是签署证书的机构。
我的问题是我能否确定服务器名称(在我的例子中是 google.com)将始终出现在第一条证书消息中。如果我只想获取服务器名,是否需要关心证书消息中的其他证书。
最佳答案
事实上,rfc 2246、4346 和 5246(分别是 TLS 1.0、TLS 1.1 和 TLS 1.2)都声明服务器证书应该是第一个:
"This is a sequence (chain) of X.509v3 certificates. The sender's certificate must come first in the list. Each following certificate must directly certify the one preceding it."
在 SSL 3.0 中也很清楚:
" certificate_list: This is a sequence (chain) of X.509.v3
certificates, ordered with the sender's certificate first followed
by any certificate authority certificates proceeding sequentially
upward."
但在现实世界中,有很多配置错误的服务器以任意顺序发送证书,因此您将不得不重新排序,抱歉。
关于ssl - TLS 握手 "certificate"消息中的多个证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15829040/