首页 > 解决方案 > Python 请求 - SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')

问题描述

从 linux 执行时,以下 curl 命令可以正常工作 -

curl -w "\n" -k --cert ~/pace.crt --key ~/pace.key --header "Accept: application/json" "https://url" -X GET;

当我尝试使用 python 请求从 url 获取响应时,我收到 ssl 错误:

certVal = ('location/pace.cert', 'location/pace.key')
methodName = 'GET'
urlLink = 'https://LinkToAdeviceConnectedToPC'
headersVal = {'Accept': 'application/json'}
res = requests.request(method=methodName, url=urlLink, headers=headersVal, cert=certVal)

错误:

Max retries exceeded with url: urllink (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

我尝试了论坛中建议的解决方案,但没有奏效。

标签: pythonpython-requests

解决方案


推荐阅读