python [SSL] PEM 库 (_ssl.c :3309) error when verifying certificate

标签 python python-3.x ssl ssl-certificate

我正在尝试将 POST 消息发送到 Web 服务器。 为此,我使用 python 请求并尝试将证书作为参数传递给 requests.post 方法。

看起来像这样:

    if method_type == METHOD_TYPE_GET:
        resp = requests.get(base_url, data=request_data, verify=True, headers=headers, cert=certificate)
    if method_type == METHOD_TYPE_POST:
        resp = requests.post(base_url, data=request_data, verify=True, headers=headers, cert=certificate)
    return resp

当'certificate' 是包含服务器证书的pem 文件的路径时。文件格式:

-----开始证书-----

-base64数据-

-----证书结束-----

当我尝试执行 post 方法时,出现以下异常:[SSL] PEM lib (_ssl.c:3309)

知道问题出在哪里吗?

最佳答案

请检查您的 openssl - 配置文件中以下参数的设置 extendedKeyUsage = clientAuth

关于python [SSL] PEM 库 (_ssl.c :3309) error when verifying certificate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42789476/

相关文章:

python - 用python压缩字符

python-3.x - 找不到 matplotlib 数据文件

python - Pylab/Matplotlib 将多个饼图合并为一个 PDF

ssl - 无法使用 Wireshark 解密 HTTPS 流量

apache - 使用 MAMP (4.0.6) 同时运行 SSL 和非 SSL 站点

ssl - keytool -importkeystore 似乎不起作用

python - 将 pandas 数据帧保存到 csv 时如何保留 numpy 数组

python - Django-CMS复用插件实例

python - 如何使python3.2解释器成为debian中的默认解释器

Python 3 readline() 不起作用