首页 > 解决方案 > SSLError:CertificateError: 主机名不匹配

问题描述

我尝试使用 Python 的请求库访问这个网站https://gss.mof.gov.cn/zhengwuxinxi/zuixingengxin/并得到一个 SSL 错误。

我已经尝试过针对类似问题给出的解决方案,但它们并没有解决我的问题。

我使用的代码:

requests.get(url='https://gss.mof.gov.cn/zhengwuxinxi/zuixingengxin/', timeout=20)

我得到的错误:

HTTPSConnectionPool(host='gss.mof.gov.cn', port=443): Max retries exceeded with url: /zhengwuxinxi/zuixingengxin/ (Caused by SSLError(CertificateError("hostname 'gss.mof.gov.cn' doesn' t 匹配 '*.chinacache.com', 'chinacache.com'",),))

标签: python-3.xpython-requestscertificate-error

解决方案


该站点正在使用不属于它的证书。openssl s_client确认证书对*.chinacache.com. 对 python 设置的任何修改都不会使与站点的连接安全。该站点的所有者将必须获得与该站点的主机名匹配的新证书。


推荐阅读