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

相关推荐
Risehuxyc1 小时前
MTU 和 MSS 详解
网络·智能路由器
ikgy1 小时前
JAVA EE:7.网络初识
网络
AlanAshley3 小时前
移动端省流方案:压缩+缓存
网络·缓存
EmbeddedChen3 小时前
Linux 怎么查看 IP 地址和网络状态?常用网络命令入门
linux·网络·ip·route·ping
FakeOccupational3 小时前
fpga系列 HDL : 选择RAM IP(Two Port IP核) 乒乓缓冲(Ping-Pong Buffer)工作流程
网络协议·tcp/ip·fpga开发
牙牙7054 小时前
接口一直超时,后端却查不出问题:TIME_WAIT 把本地端口耗尽了
linux·网络·tcp·连接池·故障排查·time_wait
郝学胜-神的一滴16 小时前
Effective STL 条款09:慎重选择删除元素的方法
开发语言·网络·数据结构·c++·算法·stl
飞花漫卷,情随岁迁21 小时前
网络数据包转发与内核机制:小白概念科普
linux·运维·网络·数据库·mysql·oracle·智能路由器
laozhang7001 天前
自己动手写一个 WebSocket 调试工具:告别广告与限制
网络·websocket·网络协议