跳到主要内容

4. TLS 客户端和服务器握手行为

4. TLS 客户端和服务器握手行为

本规范按照 [RFC5246] 中定义的扩展过程, 扩展 ClientHello 和 ServerHello 消息. 它不扩展或修改任何其他 TLS 消息.

注意: 使用原始公钥不需要新的密码套件. 所有支持与所定义扩展兼容的密钥交换方法的现有密码套件都可以使用.

图 5 中的高层消息交换展示了加入客户端和服务器 hello 消息的 client_certificate_typeserver_certificate_type 扩展.

 client_hello,
client_certificate_type,
server_certificate_type ->

<- server_hello,
client_certificate_type,
server_certificate_type,
certificate,
server_key_exchange,
certificate_request,
server_hello_done
certificate,
client_key_exchange,
certificate_verify,
change_cipher_spec,
finished ->

<- change_cipher_spec,
finished

Application Data <-------> Application Data

图 5: 基本原始公钥 TLS 交换

4.1. Client Hello

为了表示支持原始公钥, 客户端在扩展 client hello 消息中包含 client_certificate_type 和/或 server_certificate_type 扩展. hello 扩展机制见 TLS 1.2 [RFC5246] 第 7.4.1.4 节.

client hello 中的 client_certificate_type 扩展表示当使用 certificate_request 消息请求时, 客户端能够向服务器提供的证书类型.

client hello 中的 server_certificate_type 扩展表示当服务器随后在 certificate 载荷中提供证书时, 客户端能够处理的证书类型.

client hello 中发送的 client_certificate_typeserver_certificate_type 扩展各自携带一个受支持证书类型列表, 按客户端偏好排序. 当客户端仅支持一种证书类型时, 该列表只包含一个元素.

如果 TLS 客户端没有相应的原始公钥或证书可在使用 certificate_request 消息请求时提供给服务器, 或者未配置为与给定 TLS 服务器使用该类型, 则它 MUST 从 client hello 的 client_certificate_type 扩展中省略该证书类型. 如果除默认 X.509 类型外, 客户端没有剩余证书类型可在 client hello 中发送, 则它 MUST 在 client hello 中省略 client_certificate_type 扩展.

如果 TLS 客户端无法处理相应的原始公钥或其他证书类型, 则它 MUST 从 client hello 的 server_certificate_type 扩展中省略该证书类型. 如果除默认 X.509 证书类型外, 客户端没有剩余证书类型可在 client hello 中发送, 则它 MUST 从 client hello 中省略整个 server_certificate_type 扩展.

4.2. Server Hello

如果服务器收到包含 client_certificate_type 扩展和/或 server_certificate_type 扩展的 client hello, 则可能出现三种结果:

  1. 服务器不支持本文档中定义的扩展. 在这种情况下, 服务器返回的 server hello 不包含本文档中定义的扩展.

  2. 服务器支持本文档中定义的扩展, 但与客户端没有任何共同的证书类型. 此时, 服务器使用类型为 "unsupported_certificate" 的 fatal alert 终止会话.

  3. 服务器支持本文档中定义的扩展, 并且与客户端至少有一种共同的证书类型. 在这种情况下, 遵循下文描述的处理规则.

client hello 中的 client_certificate_type 扩展表示当使用 certificate_request 消息请求时, 客户端能够向服务器提供的证书类型. 如果 TLS 服务器希望通过 certificate_request 消息向客户端请求证书, 它 MUST 在 server hello 中包含 client_certificate_type 扩展. server hello 中的该 client_certificate_type 扩展随后表示请求客户端在后续 certificate 载荷中提供的证书类型. client_certificate_type 扩展中传达的值 MUST 从 client hello 中发送的 client_certificate_type 扩展所提供的值之一中选择. 服务器 MUST 还在 server hello 消息中包含 certificate_request 载荷.

如果服务器不发送 certificate_request 载荷 (例如因为客户端认证发生在应用层, 或不需要客户端认证), 或者客户端支持的证书 (如 client hello 中 client_certificate_type 扩展所示) 没有任何一种与服务器支持的证书类型匹配, 则 server hello 中的 client_certificate_type 载荷 MUST 被省略.

client hello 中的 server_certificate_type 扩展表示当服务器随后在 certificate 载荷中提供证书时, 客户端能够处理的证书类型. 如果 client hello 在 server_certificate_type 扩展中表示支持原始公钥, 且服务器选择使用原始公钥, 则 TLS 服务器 MUST 将 SubjectPublicKeyInfo 结构放入 Certificate 载荷. TLS 服务器通过 server hello 中的 server_certificate_type 扩展表示 Certificate 载荷中携带的证书类型. 由于 Certificate 载荷可能包含 X.509 证书或 SubjectPublicKeyInfo 结构, 这一附加指示可避免解析歧义. 注意, 当 server_certificate_type 扩展携带在 server hello 中时, 只允许一个值.

4.3. 客户端认证

当 TLS 服务器已将 RawPublicKey 指定为 client_certificate_type 时, 仅支持通过带外方法认证收到的客户端 SubjectPublicKeyInfo, 来完成 TLS 客户端对 TLS 服务器的认证.

4.4. 服务器认证

当 TLS 服务器已将 RawPublicKey 指定为 server_certificate_type 时, 仅支持通过带外方法认证收到的服务器 SubjectPublicKeyInfo, 来完成 TLS 服务器对 TLS 客户端的认证.