Skip to content

Commit e1eca70

Browse files
committed
docs: Update CN translation for esp_tls.rst
1 parent 08a4a2b commit e1eca70

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/zh_CN/api-reference/protocols/esp_tls.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,29 @@ ESP-TLS 在客户端提供了多种验证 TLS 服务器的选项,如验证对
5757

5858
启用 **跳过服务器验证** 选项存在潜在风险,若未通过 API 或 ``ca_store`` 等其他机制提供服务器证书,可能导致设备与伪造身份的服务器建立 TLS 连接。
5959

60+
SNI(服务器名称指示)
61+
----------------------
62+
63+
SNI 是 TLS 协议的一个扩展,它能让客户端在 TLS 握手过程中,主动指定要连接的主机名。当服务器通过同一个 IP 地址托管多个域名时,客户端必须使用这一功能才能成功建立连接。
64+
65+
**如何确保 SNI 正常工作:**
66+
67+
* 使用 HTTPS 连接时,ESP-TLS 默认启用 SNI,无需额外配置。
68+
* 若需手动指定 SNI 主机名,请使用 :cpp:type:`esp_tls_cfg_t` 中的 ``common_name`` 字段进行设置,确保在握手过程中向服务器发送正确的主机名。
69+
* ``common_name`` 的值必须与服务器证书中的通用名称 (CN, Common Name) 完全匹配。
70+
* 需将 ``skip_common_name`` 字段设置为 ``false``,确保服务器证书能通过主机名完成正确验证。这是 SNI 正常运行的必要条件。
71+
72+
示例:
73+
74+
.. code-block:: c
75+
76+
esp_tls_cfg_t cfg = {
77+
.cacert_buf = ...,
78+
.cacert_bytes = ...,
79+
.common_name = "example.com", // SNI 主机名
80+
.skip_common_name = false, // 确保证书验证无误
81+
};
82+
6083
ESP-TLS 服务器证书选择回调
6184
----------------------------------
6285

0 commit comments

Comments
 (0)