一、问题:
在做接口自动化的时候,报错:
requests.exceptions.SSLError: HTTPSConnectionPool(host='staffssoapi123', port=443): Max retries exceeded with url:
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='staffssoapi123.baid', port=443): Max retries exceeded with url: /login (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)')))
二、解决办法:
1、在requests请求中,加 :verify=False
ret = requests.post(url, data=json.dumps(params), headers=headers,verify=False).json()
结果:requests发送成功,但是会报warmings
InsecureRequestWarning: Unverified HTTPS request is being made to host 'staffssoapi'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#

在执行接口自动化测试时遇到HTTPS连接池的SSLError问题,通过设置requests库的verify参数为False可以暂时解决问题,但会产生警告。为消除警告,需要导入特定模块并进行配置,实现无警告的HTTPS请求。

3万+

被折叠的 条评论
为什么被折叠?



