Skip to content

[SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed (_ssl.c:645) #27

Description

@o0starshine0o

在python3中当用urllib.request.urlopen或者urllib.request.urlretrieve打开一个 https 的时候会验证一次 SSL 证书, 当目标使用的是

自签名的证书

时就会爆出一个
URLError: urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)的错误消息;

在我的实践中(服务器centos7,nginx, django,Python3.5.1)本地环境和测试环境都没有问题,一旦到了正式服务器,就开始报这个错误。

对于接口

  • api.pingxx.com
  • api.weixin.qq.com

证书是没法验证的,其他情况未知。
联系pingpp的人员后表示无法复现,不清楚为什么我们的正式服务器无法验证这两个域名的证书。

解决方法是将pingpp包中的__init__.py里面verify_ssl_certs改为False,虽然有警告说最好加上验证,但至少去掉验证可以正常访问,加上验证就没法访问了···

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions