1

尝试在 python 中为 ssl 上下文设置 TLS1.3 密码时遇到问题,尤其是“TLS_AES_128_CCM_SHA256”。

操作系统:Windows 7

Python版本:3.7.4

OpenSSL 版本:1.1.1c

默认情况下,当我不设置密码套件时,可以在 TLS 握手中看到客户端确实提供了一些 TLS1.3 密码,但不是我需要的。

import ssl

if __name__ == '__main__':
    ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
    ctx.set_ciphers('TLS_AES_128_CCM_SHA256')
    print(ctx.get_ciphers())

我收到的错误:

ssl.SSLError:('没有密码可以选择。',)

4

1 回答 1

0

这是因为 set_ciphers 不适用于 TLSv1.3,因此您无法启用或禁用这些密码套件(在您的示例中,“TLS_AES_128_CCM_SHA256”就是其中之一。)

来源 = https://docs.python.org/3/library/ssl.html#ssl.SSLContext.set_ciphers

于 2021-11-05T10:52:38.370 回答