zoukankan      html  css  js  c++  java
  • 如何解决 requests.exceptions.SSLError: HTTPSConnectionPool(host='api4tst.dogotsn.cn', port=443) 问题

    问题

    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)')))

    venvlibsite-packages equestsadapters.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:workspacedogotsn_pytestvenvlibsite-packagesurllib3connectionpool.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

  • 相关阅读:
    Java 重写(Override)与重载(Overload)
    Java 继承
    Java 异常处理
    Java Scanner 类
    Java 流(Stream)、文件(File)和IO
    Java 方法
    Java 正则表达式
    Beta冲刺——代码规范、冲刺任务与计划
    Beta冲刺——凡事预则立
    Beta冲刺——问题总结博客(事后诸葛亮和组员交换事宜)
  • 原文地址:https://www.cnblogs.com/guobaozhu/p/13885238.html
Copyright © 2011-2022 走看看