在使用证书身份验证的POST请求期间发生SSLError

2024-10-02 02:32:10 发布

您现在位置:Python中文网/ 问答频道 /正文

使用Python,我试图通过基于证书的身份验证向请求发送REST请求,但有时我遇到以下异常:

requests.exceptions.SSLError: HTTPSConnectionPool(host='mywebsite', port=443): Max retries exceeded with url: /myurl (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))

我正在使用python3.7.2,并在代理之后发送请求。在

这是我的实际代码:

response = requests.request("POST", url, data=payload, proxies=PROXY, headers=headers, cert=("cert.pem", "key.key"))

我希望得到一个JSON响应,但有时会出现以下异常:

OpenSSL.SSL.SysCallError: (10054, 'WSAECONNRESET')
During handling of the above exception, another exception occurred:

ssl.SSLError: ("bad handshake: SysCallError(10054, 'WSAECONNRESET')",)
During handling of the above exception, another exception occurred:

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mywebsite', port=443): Max retries exceeded with url: /myurl (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))
During handling of the above exception, another exception occurred:

requests.exceptions.SSLError: HTTPSConnectionPool(host='mywebsite', port=443): Max retries exceeded with url: /myurl (Caused by SSLError(SSLError("bad handshake: SysCallError(10054, 'WSAECONNRESET')")))


Tags: hosturlportexceptionrequestsmaxexceptionsbad

热门问题