python - Python 3.6 中使用客户端获取服务器证书时的问题
问题描述
我正在尝试使用客户端获取服务器证书。下面是我用 Python 3.6 编写的代码的相关部分:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((mailhost, int(port)))
ctx = ssl.create_default_context()
ctx.check_hostname = True
ctx.verify_mode = ssl.CERT_REQUIRED
s = ctx.wrap_socket(s, server_hostname=mailhost)
cert_bin = s.getpeercert(True)
运行此代码后,调用“wrap_socket”方法时出现以下错误:
[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:847)
客户端具有 2017 年 11 月 2 日的 OpenSSL 1.1.0g 并运行 Ubuntu 18.04,服务器具有 2017 年 1 月 26 日的 OpenSSL 1.0.2k-fips 并运行 CentOS 7.6。
这个问题是否与不同版本的 OpenSSL 有关?
解决方案
推荐阅读
- plotly-dash - 数据表不显示切片数据框
- python - 为什么 PyCharm 不能在调试模式下显示 PyTorch Module 对象属性
- java - 添加 Firebase 性能后无法构建项目 - Android
- validation - 如何为 Asp.NET Core 3.0 的自定义 RequiredIf 属性设置客户端验证
- reporting - 2 事实表和企业想知道一个事实占另一事实的百分比
- python - 如何使用硒从无序列表中提取文本
- sql - 使用别名引用列名
- java - Android 游戏 - 当实体从列表中删除时屏幕闪烁
- spring - Spring [Boot] Security and Oracle IDCS: [invalid_id_token] 尝试解码 Jwt: Malformed Jwk set 时出错
- html - 缩小屏幕尺寸时如何防止水平容器重叠或移动?