gpt4 book ai didi

python - 属性错误: module 'ssl' has no attribute 'PROTOCOL_TLSv1_3'

转载 作者:行者123 更新时间:2023-12-03 07:51:29 74 4
gpt4 key购买 nike

我正在尝试在 python 中设置 tls 上下文。我想强制使用 TLSv1.3:

context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_3)

这不起作用,因为我收到以下错误:

AttributeError: module 'ssl' has no attribute 'PROTOCOL_TLSv1_3'

我使用的是 Ubuntu 20.04,并且使用 python 版本 3.8 和 openssl 版本 1.1.1f。

为什么不支持 TLSv1.3?

最佳答案

TLS 1.3 协议(protocol)将在 OpenSSL >= 1.1.1 中与 PROTOCOL_TLS 一起使用。仅 TLS 1.3 没有专用的协议(protocol)常量。

https://docs.python.org/3.11/library/ssl.html#ssl.SSLContext

脚注3。

根据协议(protocol)版本说明,将 TLS 1.3 设置为支持的最低版本:

client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
client_context.minimum_version = ssl.TLSVersion.TLSv1_3
client_context.maximum_version = ssl.TLSVersion.TLSv1_3

https://docs.python.org/3.11/library/ssl.html#protocol-versions

https://docs.python.org/3.11/library/ssl.html#tls-1-3

关于python - 属性错误: module 'ssl' has no attribute 'PROTOCOL_TLSv1_3' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76992421/

74 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com