python-3.x - 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'",),))
解决方案
该站点正在使用不属于它的证书。openssl s_client
确认证书对*.chinacache.com
. 对 python 设置的任何修改都不会使与站点的连接安全。该站点的所有者将必须获得与该站点的主机名匹配的新证书。
推荐阅读
- sql-server - 我如何实现“如果不存在,则使用参数创建过程”?
- c# - 使用 POSTMAN 发布数据:ASP.Net
- sql - JOIN 中表的顺序
- android - 清除存储后,已删除的文件仍显示在我的应用程序中
- c# - 使用 C# 解析 Json 到课堂
- python - SQLAlchemy 游标:AttributeError:“元组”对象没有属性“项目”
- python-3.x - python中的字符串替换是替换整个字符串
- node.js - 在 Restify 中提供子路径文件
- reactjs - 使用 React Hooks 更改数组中的对象属性不会引起重新渲染
- bash - 带有 awk 的脚本不适用于 Crontab