问题

E requests.exceptions.SSLError: HTTPSConnectionPool(host='XXXXX.cn', port=443): Max retries exceeded with url: /app/login(Caused by SSLError(SSLCertVer
ificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)')))

venv\lib\site-packages\requests\adapters.py:514: SSLError

 

步骤一

先检查pip有没安装cryptography,pyOpenSSL,certifi(一般安装以下第三方库,即可解决问题)
pip install cryptography
pip install pyOpenSSL
pip install certifi

安装第三方库:pip install --index-url http://mirrors.aliyun.com/pypi/simple/ certifi --trusted-host mirrors.aliyun.com

步骤二

要是以上这些已安装还是继续报错,则在网页请求代码中加上   verify=False(关闭证书验证)   就可以解决报错,代码可运行。

 

产生的额外问题

加入步骤二后,会导致urllib3  在控制台给出警告信息,如下

=================================================================================== warnings summary =================================================================================== testcases/test_roles_privileges.py::test_dogotsn_todayCalc f:\workspace\dogotsn_pytest\venv\lib\site-packages\urllib3\connectionpool.py:988: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificat e verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

InsecureRequestWarning,

解决方法

在语句前加上以下代码即可不会被报错:
requests.packages.urllib3.disable_warnings()

 

 

 

然后在运行脚本,发现不会再出现警告!

 

 

转载博客1:https://www.codeprj.com/blog/bab39f1.html

转载博客2:https://www.jianshu.com/p/7bacf7d9ae5a

转载博客3:https://www.cnblogs.com/jackzz/p/10686113.html

转载博客4:https://www.cnblogs.com/ernana/p/8601789.html