vistal 发表于 2024-9-7 20:54

[SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1006)'))

本帖最后由 vistal 于 2024-9-7 20:58 编辑

请问各位大佬 有什么问题可以解决 只能降级Python吗?试过安装requests==2.25.1   urllib3==1.25.11 故障依旧G站和度娘 还有通义都问过了,目前还没有答案所以来请教各位大佬
File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 670, in urlopen    httplib_response = self._make_request(                     ^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 381, in _make_request    self._validate_conn(conn)File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn    conn.connect()File "/usr/local/lib/python3.11/site-packages/urllib3/connection.py", line 362, in connect    self.sock = ssl_wrap_socket(                ^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/urllib3/util/ssl_.py", line 386, in ssl_wrap_socket    return context.wrap_socket(sock, server_hostname=server_hostname)         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/ssl.py", line 517, in wrap_socket    return self.sslsocket_class._create(         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/ssl.py", line 1104, in _create    self.do_handshake()File "/usr/local/lib/python3.11/ssl.py", line 1382, in do_handshake    self._sslobj.do_handshake()ssl.SSLError: dh key too small (_ssl.c:1006)During handling of the above exception, another exception occurred:Traceback (most recent call last):File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 439, in send    resp = conn.urlopen(         ^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 726, in urlopen    retries = retries.increment(            ^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 446, in increment    raise MaxRetryError(_pool, url, error or ResponseError(cause))urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='wapside.xxx.cn', port=9001): Max retries exceeded with url: /jt-sign/ssoHomLogin?ticket=5d8042e745c167ed850fbd12014fe6bcbbf4a913e82fe3c3e6025f0a689cdc5d4e75da84110d7cc817d2ad503565e56d220045c5d82b71e0131aab244b803f94267566f7b1a313c5452f7bc3f39cdc785e7c4104885150a3cfc441d51a57d68e (Caused by SSLError(SSLError(1, ' dh key too small (_ssl.c:1006)')))During handling of the above exception, another exception occurred:Traceback (most recent call last):File "/ql/data/scripts/dx/dx2.py", line 142, in <module>    telecom.main()File "/ql/data/scripts/dx/dx2.py", line 114, in main    self.init()File "/ql/data/scripts/dx/dx2.py", line 55, in init    self.sign = self.getSign(self.ticket)                ^^^^^^^^^^^^^^^^^^^^^^^^^File "/ql/data/scripts/dx/dx2.py", line 48, in getSign    resp = get(url=url, params=data).json()         ^^^^^^^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 76, in get    return request('get', url, params=params, **kwargs)         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 61, in request    return session.request(method=method, url=url, **kwargs)         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 542, in request    resp = self.send(prep, **send_kwargs)         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 655, in send    r = adapter.send(request, **kwargs)      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 514, in send    raise SSLError(e, request=request)requests.exceptions.SSLError: HTTPSConnectionPool(host='wapside.xxxcn', port=9001): Max retries exceeded with url: /jt-sign/ssoHomLogin?ticket=5d8042e745c167ed850fbd12014fe6bcbbf4a913e82fe3c3e6025f0a689cdc5d4e75da84110d7cc817d2ad503565e56d220045c5d82b71e0131aab244b803f94267566f7b1a313c5452f7bc3f39cdc785e7c4104885150a3cfc441d51a57d68e (Caused by SSLError(SSLError(1, ' dh key too small (_ssl.c:1006)')))

wuaipojie_lbw 发表于 2024-9-8 14:20

这两种方式你可以试下
1、更新库和Python版本:确保你使用的是最新版本的requests、urllib3和Python。新版本通常包含对更强大安全协议的支持。

2、指定更高的加密密钥:你可以通过设置默认密码字符串来避免使用弱DH密钥。例如:
import requests
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL'
response = requests.get('https://example.com')
print(response.content)

vistal 发表于 2024-9-8 17:00

wuaipojie_lbw 发表于 2024-9-8 14:20
这两种方式你可以试下
1、更新库和Python版本:确保你使用的是最新版本的requests、urllib3和Python。新版 ...
谢谢我试试
页: [1]
查看完整版本: [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:1006)'))