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

相关推荐
我科绝伦(Huanhuan Zhou)9 小时前
Systemctl 与 Systemd 全面指南:Linux 系统服务管理详解
linux·服务器·网络
world-wide-wait9 小时前
python高级05——HTTP协议和静态服务器
网络·网络协议·http
止水编程 water_proof9 小时前
Java--网络编程(二)
java·开发语言·网络
Ankie Wan10 小时前
ARP: Address Resolution Protocol (ARP),IP转mac address
网络协议·tcp/ip·rfc·arp
沐浴露z10 小时前
【深入理解计算机网络10】UDP协议详解
网络·网络协议·计算机网络·udp
KnowSafe11 小时前
iTrustSSL和RapidSSL哪个性价比更高?
ssl·rapidssl·itrustssl
world-wide-wait11 小时前
python高级04——网络编程
linux·服务器·网络
特种加菲猫11 小时前
网络协议分层:解密TCP/IP五层模型
linux·网络·笔记
conkl12 小时前
Linux IP 网络配置与管理详解
linux·网络·tcp/ip
Yana.nice13 小时前
sshd -t与-T的区别
网络