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

  • 相关阅读:
    模拟63 题解
    MYSQL:python 3.x连接数据库的方式
    MYSQL: Starting MySQL….. ERROR! The server quit without updating PID file解决办法
    MYSQL:数据库安装 windows
    Python线程:线程的调度-守护线程
    Visulalization Voronoi in OpenSceneGraph
    Plant Design Review Based on AnyCAD
    Change Line Type in OpenCascade
    Topology and Geometry in OpenCascade-Adapters
    Conversion Operators in OpenCascade
  • 原文地址:https://www.cnblogs.com/guobaozhu/p/13885238.html
Copyright © 2011-2022 走看看