<i id='moccv'><tr id='moccv'><dt id='moccv'><q id='moccv'><span id='moccv'><b id='moccv'><form id='moccv'><ins id='moccv'></ins><ul id='moccv'></ul><sub id='moccv'></sub></form><legend id='moccv'></legend><bdo id='moccv'><pre id='moccv'><center id='moccv'></center></pre></bdo></b><th id='moccv'></th></span></q></dt></tr></i><div id='moccv'><tfoot id='moccv'></tfoot><dl id='moccv'><fieldset id='moccv'></fieldset></dl></div>
    <tfoot id='moccv'></tfoot>

      <small id='moccv'></small><noframes id='moccv'>

        <bdo id='moccv'></bdo><ul id='moccv'></ul>
    1. <legend id='moccv'><style id='moccv'><dir id='moccv'><q id='moccv'></q></dir></style></legend>

      SSL:CERTIFICATE_VERIFY_FAILED 证书验证失败

      时间:2023-07-06

      <small id='3LUIp'></small><noframes id='3LUIp'>

        <tbody id='3LUIp'></tbody>

      <i id='3LUIp'><tr id='3LUIp'><dt id='3LUIp'><q id='3LUIp'><span id='3LUIp'><b id='3LUIp'><form id='3LUIp'><ins id='3LUIp'></ins><ul id='3LUIp'></ul><sub id='3LUIp'></sub></form><legend id='3LUIp'></legend><bdo id='3LUIp'><pre id='3LUIp'><center id='3LUIp'></center></pre></bdo></b><th id='3LUIp'></th></span></q></dt></tr></i><div id='3LUIp'><tfoot id='3LUIp'></tfoot><dl id='3LUIp'><fieldset id='3LUIp'></fieldset></dl></div>
        <legend id='3LUIp'><style id='3LUIp'><dir id='3LUIp'><q id='3LUIp'></q></dir></style></legend>

        1. <tfoot id='3LUIp'></tfoot>
              <bdo id='3LUIp'></bdo><ul id='3LUIp'></ul>

                本文介绍了SSL:CERTIFICATE_VERIFY_FAILED 证书验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                从 lxml 导入 html导入请求url = "https://website.com/"page = requests.get(url)树 = html.fromstring(page.content)页面内容

                -> SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:748)

                我运行了这个脚本,但我得到了这个错误.我该怎么做?

                解决方案

                由于您的 URL 是内部公司 URL"(如评论中所述),我猜它使用自签名证书,或者由自签名 CA 证书.

                如果确实如此,您有两种选择:

                (1) 提供您公司 CA 的路径(包括完整的中间证书链,如果有的话)到 requests.get() 通过 verify 参数调用:

                requests.get('https://website.lo', verify='/path/to/certfile')

                (2),完全禁用客户端证书验证(但注意所有安全风险,这就像一个简单的中间人攻击等):

                requests.get('https://website.lo', verify=False)

                为了完整性,相关的 verify 参数在 requests.request() 文档:

                <块引用>

                verify --(可选)布尔值,在这种情况下它控制我们是否验证服务器的 TLS 证书或字符串,在这种情况下它必须是路径到要使用的 CA 捆绑包.默认为真.

                from lxml import html
                import requests
                
                
                url = "https://website.com/"
                page = requests.get(url)
                tree = html.fromstring(page.content)
                page.content
                

                -> SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)

                I run this script but I got this error. How can I do it?

                解决方案

                Since your URL is "an internal corporate URL" (as stated in comments), I'm guessing it uses a self-signed certificate, or is issued by a self-signed CA certificate.

                If that is in fact the case, you have two options:

                (1) provide the path to your corporate CA (including the complete chain of intermediate certificates, if any) to requests.get() call via verify argument:

                requests.get('https://website.lo', verify='/path/to/certfile')
                

                or (2), disable client-side certificate verification altogether (but beware of all the security risks this entails, like a simple man-in-the-middle attacks, etc):

                requests.get('https://website.lo', verify=False)
                

                Fore completeness, the relevant verify parameter is described in requests.request() docs:

                verify -- (optional) Either a boolean, in which case it controls whether we verify 
                          the server's TLS certificate, or a string, in which case it must be a path 
                          to a CA bundle to use. Defaults to True.
                

                这篇关于SSL:CERTIFICATE_VERIFY_FAILED 证书验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:XHR 请求 URL 在尝试解析其内容时说不存在 下一篇:自动创建 requirements.txt

                相关文章

                  1. <i id='MbArw'><tr id='MbArw'><dt id='MbArw'><q id='MbArw'><span id='MbArw'><b id='MbArw'><form id='MbArw'><ins id='MbArw'></ins><ul id='MbArw'></ul><sub id='MbArw'></sub></form><legend id='MbArw'></legend><bdo id='MbArw'><pre id='MbArw'><center id='MbArw'></center></pre></bdo></b><th id='MbArw'></th></span></q></dt></tr></i><div id='MbArw'><tfoot id='MbArw'></tfoot><dl id='MbArw'><fieldset id='MbArw'></fieldset></dl></div>

                      <bdo id='MbArw'></bdo><ul id='MbArw'></ul>
                    <legend id='MbArw'><style id='MbArw'><dir id='MbArw'><q id='MbArw'></q></dir></style></legend><tfoot id='MbArw'></tfoot>
                  2. <small id='MbArw'></small><noframes id='MbArw'>