使用Python Requests模块发送请求时遭遇SSL握手失败错误求助
Python requests发送POST请求遭遇SSL握手失败问题
代码实现
import requests headers = { 'Accept': 'application/json, text/plain, */*', 'Accept-Language': 'en-US,en;q=0.9,ur;q=0.8,bg;q=0.7', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'Origin': 'https://example.com', 'Referer': 'https://example.com/', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36', 'dnt': '1', 'sec-ch-ua': '"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"Windows"', 'sec-gpc': '1', } json_data = { 'session':'123' } response = requests.post( 'https://example.com', headers=headers, json=json_data ) print(response.content)
错误信息
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\John\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 517, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='exammple.com', port=443): Max retries exceeded with url: /data (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1002)')))
已尝试的解决方案
- 设置
verify=False,无效 - 指定证书文件
verify=server.cer,无效 - 确认网站使用GoDaddy根证书,从浏览器导出后使用,无效
- 将证书转换为.pem格式后使用,无效
- 浏览器和BurpSuite发送请求可正常响应,但requests模块不行
请求协助解决此SSL握手失败问题。
内容的提问来源于stack exchange,提问作者Risen_Star
相关产品推荐
相关产品推荐

