[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博客

相关推荐
岸边的风21 分钟前
无需公网IP的文件交互:FileCodeBox容器化部署技术解析
网络·网络协议·tcp/ip
Zonda要好好学习1 小时前
Python入门Day4
java·网络·python
2501_915374351 小时前
UDP vs TCP:核心差异与应用场景全解析
网络协议·tcp/ip·udp
Edingbrugh.南空1 小时前
操作系统级TCP性能优化:高并发场景下的内核参数调优实践
网络协议·tcp/ip·性能优化
riverz12271 小时前
TCP backlog工作机制
服务器·网络·tcp/ip
yqcoder2 小时前
1. http 有哪些版本,你是用的哪个版本,怎么查看
网络·网络协议·http
Fanmeang5 小时前
OSPF路由过滤
运维·网络·华为·ip·路由·ospf·路由过滤
2501_915918416 小时前
接口漏洞怎么抓?Fiddler 中文版 + Postman + Wireshark 实战指南
websocket·网络协议·tcp/ip·http·网络安全·https·udp
我是阿呆同学6 小时前
仿mudou库one thread oneloop式并发服务器
网络
是阿建吖!6 小时前
【Linux | 网络】网络编程套接字
linux·网络