向服务器发送请求时报以下错误:

ssl.SSLCertVerificationError:[SSL:CERTIFICATE_VERIFY_FAILED] certificate verify failed:self signed certificate in certificate chain(_ssl.c:1076)

解决:

方案1、服务器使用的是自签名的ssl证书。可使用verify值为的可选参数构建客户端False,禁用所有ssl检查。

方案2、

import ssl

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
    pass
else:
    # Handle target environment that doesn't support HTTPS verification
    ssl._create_default_https_context = _create_unverified_https_context

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐