SSL:CERTIFICATE_VERIFY_FAILED证书验证失败 [英] SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed

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

问题描述

from lxml import html
import requests


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

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

我运行了此脚本,但出现此错误.我该怎么办?

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

推荐答案

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

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)提供到(2),完全禁用客户端证书验证(但请注意所有安全风险,就像一个简单的中间人一样)攻击等):

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)

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

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证书验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆