Python 用 python 发送 requests 请求,带有证书 和密码的,但是响应报错 (Caused by SSLError(SSLError(398, '[SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:4024)')

岩岩 · 2021年09月02日 · 最后由 cheunghr 回复于 2021年09月06日 · 3800 次阅读

#res=requests.get(url='https://**/heibes/goods',headers=headers,params=data,verify=False)
resp = requests.get('https://
**/heibes/goods',headers=headers, data=data,
cert=('D:\2029_https\client.crt', 'D:\2029_https\client.key'),verify=False)
print(resp.text)

报错信息:
Traceback (most recent call last):
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self.make_request(
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\ssl
.py", line 397, in ssl_wrap_socket
context.load_cert_chain(certfile, keyfile)
ssl.SSLError: [SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:4024)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.xuandonline.com', port=443): Max retries exceeded with url: /heibes/goods (Caused by SSLError(SSLError(398, '[SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:4024)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:/logic/testcase/goods.py", line 17, in
resp = requests.get('https://api.xuandonline.com/heibes/goods,headers=headers', data=data, cert=('D:\2029_https\client.crt', 'D:\2029_https\client.key'), verify=False)
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\zx\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.xuandonline.com', port=443): Max retries exceeded with url: /heibes/goods (Caused by SSLError(SSLError(398, '[SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:4024)')))

Process finished with exit code 1

请问各位大神是什么原因? 据说的要把证书转成 sha 加密,但是如何转呢?

共收到 3 条回复 时间 点赞

CA_MD_TOO_WEAK] ca md too weak

我来试着翻译一下这个错误信息:
擦,md ,太弱了

Jerry li 回复

哈哈哈哈

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册