python - "SSLError: [SSL] PEM lib (_ssl.c:2532)"是什么意思使用 Python ssl 库?

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

我正在尝试使用 Python 3 asyncio 模块连接到另一方并收到此错误:

     36     sslcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
---> 37     sslcontext.load_cert_chain(cert, keyfile=ca_cert)
     38

SSLError: [SSL] PEM lib (_ssl.c:2532)

问题是错误的含义。我的证书是正确的, key 文件(CA 证书)可能不正确

最佳答案

假设使用的是 3.6 版:

见:https://github.com/python/cpython/blob/3.6/Modules/_ssl.c#L3523-L3534

 PySSL_BEGIN_ALLOW_THREADS_S(pw_info.thread_state);
 r = SSL_CTX_check_private_key(self->ctx);
 PySSL_END_ALLOW_THREADS_S(pw_info.thread_state);
 if (r != 1) { 
    _setSSLError(NULL, 0, __FILE__, __LINE__);
    goto error;
 }

它的意思是 SSL_CTX_check_private_key 失败;因此,私钥不正确。

引用可能的版本:

关于python - "SSLError: [SSL] PEM lib (_ssl.c:2532)"是什么意思使用 Python ssl 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30109449/

相关文章:

python - 保留最大绝对值并返回具有重复索引的行的平均值

ssl - SChannel,SEC_E_ALGORITHM_MISMATCH (0x80090331)

Python,括号前的下划线有什么作用

Python 列表连接——在开头或结尾包含分隔符

python - `not x in y` 是否遵循运算符优先级规则?

node.js - 本地网络上的 Websocket 奇怪延迟

java - 通过 SSL 的 LDAP 连接不适用于参数 "com.sun.jndi.ldap.connect.timeout"

python - 使用 matplotlib plt.barh 时 invert_xaxis 给出错误

python - 在 Python 中将整数转换为 2 字节的十六进制值

python - 仍然找到安装了 pyenv 的系统 python - 安装模块