[SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED]

使用requess库访问https网址时,返回

(Caused by SSLError(SSLError(1, 'SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED unsafe legacy renegotiation disabled (_ssl.c:1147)')))

原因可能是服务器的认证方式版本太低然后requests抛弃了这种认证方式

参考:python - SSL error unsafe legacy renegotiation disabled - Stack Overflow

解决方法

python 复制代码
import ssl
import urllib.request

url = ""

# Set up SSL context to allow legacy TLS versions
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
ctx.options |= 0x4  # OP_LEGACY_SERVER_CONNECT

# Use urllib to open the URL and read the content
response = urllib.request.urlopen(url, context=ctx)
print(response.read().decode())

补充,或者这种(把代理部分的参数去掉)

解决tls版本问题的同时使用代理-CSDN博客

相关推荐
小乖写代码7 小时前
提交注册验证 · WhatsApp /v2/register
android·网络·账号注册
多弗朗皮卡丘8 小时前
网络基础:数据链路层与其他协议或技术
linux·网络·tcp/ip
我不会插花弄玉13 小时前
9.数据链路层【由浅入深-网络】
网络
进击的荆棘21 小时前
Linux网络——网络基础概念
linux·运维·服务器·网络
LightBreeze200221 小时前
从 LSA 到路由计算,彻底理解 OSPF 的区域路由与防环机制
网络·智能路由器·ospf·lsa·spf
忆挽篱笙歌1 天前
通信连接,匿名管道
linux·服务器·网络
九英里路1 天前
protobuf快速上手
网络·c++·中间件·json·谷歌·序列化·protobuf
女神下凡2 天前
芯参谋(107):杰理AC_中科蓝讯_开发指南
linux·服务器·网络·单片机·嵌入式硬件
爱和冰阔落2 天前
【Linux网络】TCP 半包粘包怎么解决?从长度报头、JSON 拆包到网络计算器完整实战
linux·运维·网络·tcp/ip
say_fall2 天前
【Linux网络编程】UDP套接字编程:系统编程组件、基础回显服务、InetAddr与地址转换、翻译服务与线程池聊天室
linux·服务器·网络·udp·vr