You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修复Python3中LinkFinder工具的ssl.PROTOCOL_TLSv1_2已弃用警告?

Fixing the SSL Deprecation Warning in LinkFinder (Python 3)

I ran into this exact warning a while back when using LinkFinder—here's how to fix it cleanly:

The warning comes from line 133 in linkfinder.py, where the code explicitly initializes an SSL context with ssl.PROTOCOL_TLSv1_2—a constant that's been deprecated in newer Python releases because hardcoding specific TLS versions isn't secure or future-proof.

Here are two solid solutions, starting with the best practice:

This is the safest and simplest fix. Python's create_default_context() method automatically uses the most secure TLS versions supported by your system, eliminating the need to hardcode a deprecated protocol.

  • Open your linkfinder.py file and navigate to line 133:
    sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
    
  • Replace that line entirely with:
    sslcontext = ssl.create_default_context()
    
  • Save the file, run LinkFinder again, and the warning should be gone. Bonus: You'll be using a more secure SSL setup than before.

2. Explicitly Use a Supported TLS Protocol (If You Need Control)

If you have a specific reason to enforce a range of TLS versions (e.g., testing against older servers), you can use non-deprecated constants instead:

  • For client-side connections (which LinkFinder uses), replace line 133 with:
    sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
    # Optional: Lock down TLS versions if required
    sslcontext.min_version = ssl.TLSVersion.TLSv1_2
    sslcontext.max_version = ssl.TLSVersion.TLSv1_3
    
  • This uses a supported protocol constant while still letting you define acceptable TLS versions if needed.

Quick Background

Python deprecated ssl.PROTOCOL_TLSv1_2 because modern security practices prioritize letting the client and server negotiate the highest secure TLS version they both support. Using create_default_context() handles this negotiation automatically, so you don't have to worry about outdated protocols.

内容的提问来源于stack exchange,提问作者kylojshan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 21:42:26