我在试着用urllib.request.urlopen在以“https”开头的网站上。错误输出为:
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
有很多很好的线程可以覆盖这个错误。包括提到SSL实验室等级的this one。我可以使用urllib.request.urlopen在我测试过的每一个“https”网站上。在
SSL实验室显示以下输出:
Key RSA 2048 bits (e 65537)
Issuer Let's Encrypt Authority X3
AIA: http://cert.int-x3.letsencrypt.org/
Signature algorithm SHA256withRSA
Extended Validation No
Certificate Transparency No
OCSP Must Staple No
Revocation information OCSP
Revocation status Good (not revoked)
DNS CAA No (more info)
Trusted Yes
为了澄清,我的问题是:有没有解决方案来完成握手,其中不包括绕过证书验证?如果有一个解决方案,它能完全在linux、macOS和Windows上的python脚本中解决吗?在
我能够解决这个问题(对于基于debian的系统,我运行的是debian 9)。我仍然需要在macOS和Windows上测试解决方案。在
在SSL Labs报告的“Certification Paths”标题下,它显示:
我导航到
^{pr2}$/etc/ssl/certs/
,注意到没有Let's Encrypt
证书。然后我下载了.pem并重新编译。在我刚才测试了python的一行
page = urllib.request.urlopen('https://www.exampleSITE.com').read()
它成功地检索到了页面。在
您可以通过将丢失的中间证书添加到活动的X509Store来解决此问题:
请注意,如果您只需要与正在为其执行此操作的服务器通信,则可以将适当的}参数传递给
cafile
或{create_default_context()
。在相关问题 更多 >
编程相关推荐